@@ -6,9 +6,7 @@ package provider
66import (
77 "context"
88 "fmt"
9- "regexp"
109
11- "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
1210 "github.com/hashicorp/terraform-plugin-framework/attr"
1311 "github.com/hashicorp/terraform-plugin-framework/diag"
1412 "github.com/hashicorp/terraform-plugin-framework/path"
@@ -22,6 +20,7 @@ import (
2220 "github.com/hashicorp/terraform-plugin-framework/types/basetypes"
2321 "github.com/hashicorp/terraform-plugin-log/tflog"
2422 mondoov1 "go.mondoo.com/mondoo-go"
23+ "go.mondoo.com/terraform-provider-mondoo/internal/mondoovalidator"
2524)
2625
2726// Ensure provider defined types fully satisfy framework interfaces.
@@ -208,10 +207,7 @@ func (r *SpaceResource) Schema(ctx context.Context, req resource.SchemaRequest,
208207 MarkdownDescription : "Name of the space." ,
209208 Optional : true ,
210209 Validators : []validator.String {
211- stringvalidator .RegexMatches (
212- regexp .MustCompile (`^([a-zA-Z \-'_]|\d){2,64}$` ),
213- "must contain 2 to 64 characters, where each character can be a letter (uppercase or lowercase), a space, a dash, an underscore, or a digit" ,
214- ),
210+ mondoovalidator .Name (),
215211 },
216212 },
217213 "description" : schema.StringAttribute {
@@ -226,10 +222,7 @@ func (r *SpaceResource) Schema(ctx context.Context, req resource.SchemaRequest,
226222 stringplanmodifier .UseStateForUnknown (),
227223 },
228224 Validators : []validator.String {
229- stringvalidator .RegexMatches (
230- regexp .MustCompile (`^[a-z\d]([\d-_]|[a-z]){2,62}[a-z\d]$` ),
231- "must contain 4 to 64 digits, dashes, underscores, or lowercase letters, and ending with either a lowercase letter or a digit" ,
232- ),
225+ mondoovalidator .Id (),
233226 },
234227 },
235228 "mrn" : schema.StringAttribute {
@@ -243,10 +236,7 @@ func (r *SpaceResource) Schema(ctx context.Context, req resource.SchemaRequest,
243236 MarkdownDescription : "ID of the organization." ,
244237 Required : true ,
245238 Validators : []validator.String {
246- stringvalidator .RegexMatches (
247- regexp .MustCompile (`^[a-z\d]([\d-_]|[a-z]){4,62}[a-z\d]$` ),
248- "must contain 4 to 64 digits, dashes, underscores, or lowercase letters, and ending with either a lowercase letter or a digit" ,
249- ),
239+ mondoovalidator .Id (),
250240 },
251241 },
252242 "space_settings" : schema.SingleNestedAttribute {
0 commit comments