-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing of validation tag "required" on int, bool and string type fields #37
Comments
Service provider config has plenty of bool type fields with the validation tag "required" on |
Fields that can fail on validation tag "required"Will fail in this cases:
Schema has no fields with the validation tag "required" on int, bool or string fields Service Provider Config type patch struct {
Supported bool `json:"supported" validate:"required"`
}
type bulk struct {
Supported bool `json:"supported" validate:"required"`
MaxOperations int `json:"maxOperations" validate:"required"`
MaxPayloadSize int `json:"maxPayloadSize" validate:"required"`
}
type filter struct {
Supported bool `json:"supported" validate:"required"`
MaxResults int `json:"maxResults" validate:"required"`
}
type changePassword struct {
Supported bool `json:"supported" validate:"required"`
}
type sort struct {
Supported bool `json:"supported" validate:"required"`
}
type etag struct {
Supported bool `json:"supported" validate:"required"`
}
type authenticationScheme struct {
Type string `json:"type" validate:"required,eq=oauth|eq=oauth2|eq=oauthbearertoken|eq=httpbasic|eq=httpdigest"`
Name string `json:"name" validate:"required"`
Description string `json:"description" validate:"required"` Resource Type type SchemaExtension struct {
Schema string `json:"schema" validate:"urn,required"`
Required bool `json:"required" validate:"required"`
}
type ResourceType struct {
CommonAttributes
Name string `json:"name" validate:"required"`
Endpoint string `json:"endpoint" validate:"startswith=/,required"`
Schema string `json:"schema" validate:"urn,required"` Common type Meta struct {
Location string `json:"location" validate:"uri,required"`
ResourceType string `json:"resourceType" validate:"required"`
type CommonAttributes struct {
Schemas []string `json:"schemas" validate:"gt=0,dive,urn,required"`
// Common attributes
ID string `json:"id" validate:"excludes=bulkId,required"` cc @leogr |
I have removed the "required" validators for boolean fields of What to expect when a configuration JSON file misses the required fields? These fields will contain false values (the null values for booleans in golang). This is not a problem in the case of |
@leodido I agree. Because the different usage context (Structured Resource will be not modified by any external APIs call) we don't need that validation strictly follows RFCs. |
With validation tag "required" on bool type fields if you don't give that field value true, the test using
Validator.Struct()
it will return this error :'ResourceType.SchemaExtensions[0].Required' Error:Field validation for 'Required' failed on the 'required' tag
Fixed temporarily 6f23992 removing the required validation tag
The text was updated successfully, but these errors were encountered: