@@ -13,6 +13,7 @@ import (
1313"github.com/coder/coder/v2/coderd/util/ptr"
1414"github.com/coder/coder/v2/codersdk"
1515"github.com/coder/coder/v2/provisionersdk"
16+ "github.com/coder/terraform-provider-coderd/internal/codersdkvalidator"
1617"github.com/google/uuid"
1718"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
1819"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
@@ -258,17 +259,15 @@ func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaReques
258259MarkdownDescription :"The name of the template." ,
259260Required :true ,
260261Validators : []validator.String {
261- stringvalidator .LengthBetween (1 ,32 ),
262- stringvalidator .RegexMatches (nameValidRegex ,"Template names must be alphanumeric with hyphens." ),
262+ codersdkvalidator .Name (),
263263},
264264},
265265"display_name" : schema.StringAttribute {
266266MarkdownDescription :"The display name of the template. Defaults to the template name." ,
267267Optional :true ,
268268Computed :true ,
269269Validators : []validator.String {
270- stringvalidator .LengthBetween (1 ,64 ),
271- stringvalidator .RegexMatches (displayNameRegex ,"Template display names must be alphanumeric with spaces." ),
270+ codersdkvalidator .DisplayName (),
272271},
273272},
274273"description" : schema.StringAttribute {
@@ -418,8 +417,7 @@ func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaReques
418417Optional :true ,
419418Computed :true ,
420419Validators : []validator.String {
421- stringvalidator .LengthBetween (1 ,64 ),
422- stringvalidator .RegexMatches (templateVersionNameRegex ,"Template version names must be alphanumeric with underscores and dots." ),
420+ codersdkvalidator .TemplateVersionName (),
423421},
424422},
425423"message" : schema.StringAttribute {