Validation Results Examples
Under the hood Zog follows the Validation Execution Structure and does a bunch of things under the hood to make sure your data is validated correctly. Such as checking for zero values, etc...
Some of this might not be obvious so here is a summary table that breaksdown expected results of calling schema.Validate() on various inputs:
Schema Type | Data | Required Error (Zero Value) |
---|---|---|
Bool() | true | no |
Bool() | false | yes |
String() | "" | yes |
String() | any value | no |
Int() | 0 | yes |
Int() | 10 | no |
Float() | 0 | yes |
Float() | 1.21 | no |
Time() | time.Time{} | yes |
Time() | time.Now() | no |
Slice() | [] | yes |
Slice() | [1,2,3] | no |
Slice() | nil | yes |
Ptr(schema) | <zero_value_for_schema> | no |
Ptr(schema) | nil | yes |