@@ -12,6 +12,7 @@ import (
1212 "cdr.dev/slog"
1313 "github.com/coder/coder/v2/codersdk"
1414 "github.com/coder/coder/v2/provisionersdk"
15+ "github.com/coder/terraform-provider-coderd/internal/codersdkvalidator"
1516 "github.com/google/uuid"
1617 "github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
1718 "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
@@ -257,17 +258,15 @@ func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaReques
257258 MarkdownDescription : "The name of the template." ,
258259 Required : true ,
259260 Validators : []validator.String {
260- stringvalidator .LengthBetween (1 , 32 ),
261- stringvalidator .RegexMatches (nameValidRegex , "Template names must be alphanumeric with hyphens." ),
261+ codersdkvalidator .Name (),
262262 },
263263 },
264264 "display_name" : schema.StringAttribute {
265265 MarkdownDescription : "The display name of the template. Defaults to the template name." ,
266266 Optional : true ,
267267 Computed : true ,
268268 Validators : []validator.String {
269- stringvalidator .LengthBetween (1 , 64 ),
270- stringvalidator .RegexMatches (displayNameRegex , "Template display names must be alphanumeric with spaces." ),
269+ codersdkvalidator .DisplayName (),
271270 },
272271 },
273272 "description" : schema.StringAttribute {
@@ -417,8 +416,7 @@ func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaReques
417416 Optional : true ,
418417 Computed : true ,
419418 Validators : []validator.String {
420- stringvalidator .LengthBetween (1 , 64 ),
421- stringvalidator .RegexMatches (templateVersionNameRegex , "Template version names must be alphanumeric with underscores and dots." ),
419+ codersdkvalidator .TemplateVersionName (),
422420 },
423421 },
424422 "message" : schema.StringAttribute {
0 commit comments