skip number validator on zero-default

This commit is contained in:
Gani Georgiev
2022-11-17 22:06:31 +02:00
parent 3b9a9df171
commit 341bcc4a0e
2 changed files with 14 additions and 5 deletions
+4 -4
View File
@@ -135,7 +135,7 @@ func (validator *RecordDataValidator) checkFieldValue(field *schema.SchemaField,
func (validator *RecordDataValidator) checkTextValue(field *schema.SchemaField, value any) error {
val, _ := value.(string)
if val == "" {
return nil // nothing to check
return nil // nothing to check (skip zero-defaults)
}
options, _ := field.Options.(*schema.TextOptions)
@@ -159,11 +159,11 @@ func (validator *RecordDataValidator) checkTextValue(field *schema.SchemaField,
}
func (validator *RecordDataValidator) checkNumberValue(field *schema.SchemaField, value any) error {
if value == nil {
return nil // nothing to check
val, _ := value.(float64)
if val == 0 {
return nil // nothing to check (skip zero-defaults)
}
val, _ := value.(float64)
options, _ := field.Options.(*schema.NumberOptions)
if options.Min != nil && val < *options.Min {