diff --git a/internal/provider/resource_code_server_test.go b/internal/provider/resource_code_server_test.go index 8cc0e2c..30d9fa4 100644 --- a/internal/provider/resource_code_server_test.go +++ b/internal/provider/resource_code_server_test.go @@ -254,7 +254,7 @@ provider "restful" { resource "restful_resource" "test" { path = "/tests" - read_path = "$trim_path.url_path(body.self)" + read_path = "$url_path.trim_path(body.self)" body = {} } `, url) diff --git a/internal/validator/string_is_path_builder.go b/internal/validator/string_is_path_builder.go index 0209016..d8f036f 100644 --- a/internal/validator/string_is_path_builder.go +++ b/internal/validator/string_is_path_builder.go @@ -30,21 +30,23 @@ func (_ stringsIsPathBuilder) ValidateString(ctx context.Context, req validator. pathFuncs := buildpath.PathFuncFactory{}.Build() check := func(matches [][]string) diag.Diagnostic { for _, match := range matches { - fname, value := match[1], match[2] - if fname != "" { - if _, ok := pathFuncs[buildpath.FuncName(fname)]; !ok { - return diag.NewAttributeErrorDiagnostic( - req.Path, - "Invalid String", - fmt.Sprintf("unknown function: %s", fname), - ) - } - if !strings.HasPrefix(value, "body.") { - return diag.NewAttributeErrorDiagnostic( - req.Path, - "Invalid String", - fmt.Sprintf("value isn't a body reference"), - ) + fnames, value := match[1], match[2] + for _, fname := range strings.Split(fnames, ".") { + if fname != "" { + if _, ok := pathFuncs[buildpath.FuncName(fname)]; !ok { + return diag.NewAttributeErrorDiagnostic( + req.Path, + "Invalid String", + fmt.Sprintf("unknown function: %s", fname), + ) + } + if !strings.HasPrefix(value, "body.") { + return diag.NewAttributeErrorDiagnostic( + req.Path, + "Invalid String", + fmt.Sprintf("value isn't a body reference"), + ) + } } } }