Open ehaselwanter opened 4 months ago
The solution is described in https://developer.hashicorp.com/terraform/plugin/framework/validation, we need to implement an attribute validation:
// Typically within the schema.Schema returned by Schema() for a provider,
// resource, or data source.
schema.StringAttribute{
// ... other Attribute configuration ...
Validators: []validator.String{
// These are example validators from terraform-plugin-framework-validators
stringvalidator.LengthBetween(10, 256),
stringvalidator.RegexMatches(
regexp.MustCompile(`^[a-z0-9]+$`),
"must contain only lowercase alphanumeric characters",
),
},
}
We should use the following regex:
IDs: ^[a-z]([\d-_]|[a-z]){4,33}[a-z\d]$
Name: ^([a-zA-Z \-'_]|\d){2,30}$
@chris-rock
According to the picture, the validation should be ^[a-z]([\d-_]|[a-z]){6,35}[a-z\d]$
or am I misunderstanding something?
Another question that we are unsure of, if there should be a validation of other fields (e.g. Name of an integration), since no validation applies in the UI?
For instance, we tried to exceed 256 characters in the name string, which resulted in the error: Unable to create Domain integration, got error: client: validator failed for field "IntegrationsManager.name": value is greater than the required length
at runtime (In the UI and with Terraform). However, there was no limitation on special characters.
The space Ressource needs some input validation to meet the platform requirements
To Reproduce
with
Expected behavior
validate against:
Org / Space Name: name: letters, numbers, single quotes, hyphens, spaces or exclamation points, more then 4 chars Regex:
^([a-zA-Z \-'_]|\d){2,30}$