mirror of
https://github.com/LukeHagar/plexterraform.git
synced 2025-12-09 20:47:45 +00:00
ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.129.1
This commit is contained in:
50
internal/validators/DateValidator.go
Normal file
50
internal/validators/DateValidator.go
Normal file
@@ -0,0 +1,50 @@
|
||||
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
|
||||
|
||||
package validators
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/pkg/types"
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag"
|
||||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||
)
|
||||
|
||||
var _ validator.String = DateValidator{}
|
||||
|
||||
type DateValidator struct {
|
||||
}
|
||||
|
||||
func (validator DateValidator) Description(ctx context.Context) string {
|
||||
return "value must be a string in YYYY-MM-DD format"
|
||||
}
|
||||
|
||||
func (validator DateValidator) MarkdownDescription(ctx context.Context) string {
|
||||
return validator.Description(ctx)
|
||||
}
|
||||
|
||||
func (validator DateValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) {
|
||||
// Only validate the attribute configuration value if it is known.
|
||||
if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() {
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := types.NewDateFromString(req.ConfigValue.ValueString()); err != nil {
|
||||
resp.Diagnostics.Append(validatordiag.InvalidAttributeTypeDiagnostic(
|
||||
req.Path,
|
||||
validator.MarkdownDescription(ctx),
|
||||
req.ConfigValue.ValueString(),
|
||||
))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// IsDate returns an AttributeValidator which ensures that any configured
|
||||
// attribute value:
|
||||
//
|
||||
// - Is a String.
|
||||
// - Is in YYYY-MM-DD Format.
|
||||
//
|
||||
// Null (unconfigured) and unknown (known after apply) values are skipped.
|
||||
func IsValidDate() validator.String {
|
||||
return DateValidator{}
|
||||
}
|
||||
Reference in New Issue
Block a user