|
|
@ -321,8 +321,17 @@ equal to the parameter given. For strings, it checks that |
|
|
|
the string length is exactly that number of characters. For slices, |
|
|
|
the string length is exactly that number of characters. For slices, |
|
|
|
arrays, and maps, validates the number of items. |
|
|
|
arrays, and maps, validates the number of items. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #1 |
|
|
|
|
|
|
|
|
|
|
|
Usage: len=10 |
|
|
|
Usage: len=10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #2 (time.Duration) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For time.Duration, len will ensure that the value is equal to the duration given |
|
|
|
|
|
|
|
in the parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Usage: len=1h30m |
|
|
|
|
|
|
|
|
|
|
|
Maximum |
|
|
|
Maximum |
|
|
|
|
|
|
|
|
|
|
|
For numbers, max will ensure that the value is |
|
|
|
For numbers, max will ensure that the value is |
|
|
@ -330,8 +339,17 @@ less than or equal to the parameter given. For strings, it checks |
|
|
|
that the string length is at most that number of characters. For |
|
|
|
that the string length is at most that number of characters. For |
|
|
|
slices, arrays, and maps, validates the number of items. |
|
|
|
slices, arrays, and maps, validates the number of items. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #1 |
|
|
|
|
|
|
|
|
|
|
|
Usage: max=10 |
|
|
|
Usage: max=10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #2 (time.Duration) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For time.Duration, max will ensure that the value is less than or equal to the |
|
|
|
|
|
|
|
duration given in the parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Usage: max=1h30m |
|
|
|
|
|
|
|
|
|
|
|
Minimum |
|
|
|
Minimum |
|
|
|
|
|
|
|
|
|
|
|
For numbers, min will ensure that the value is |
|
|
|
For numbers, min will ensure that the value is |
|
|
@ -339,24 +357,51 @@ greater or equal to the parameter given. For strings, it checks that |
|
|
|
the string length is at least that number of characters. For slices, |
|
|
|
the string length is at least that number of characters. For slices, |
|
|
|
arrays, and maps, validates the number of items. |
|
|
|
arrays, and maps, validates the number of items. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #1 |
|
|
|
|
|
|
|
|
|
|
|
Usage: min=10 |
|
|
|
Usage: min=10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #2 (time.Duration) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For time.Duration, min will ensure that the value is greater than or equal to |
|
|
|
|
|
|
|
the duration given in the parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Usage: min=1h30m |
|
|
|
|
|
|
|
|
|
|
|
Equals |
|
|
|
Equals |
|
|
|
|
|
|
|
|
|
|
|
For strings & numbers, eq will ensure that the value is |
|
|
|
For strings & numbers, eq will ensure that the value is |
|
|
|
equal to the parameter given. For slices, arrays, and maps, |
|
|
|
equal to the parameter given. For slices, arrays, and maps, |
|
|
|
validates the number of items. |
|
|
|
validates the number of items. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #1 |
|
|
|
|
|
|
|
|
|
|
|
Usage: eq=10 |
|
|
|
Usage: eq=10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #2 (time.Duration) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For time.Duration, eq will ensure that the value is equal to the duration given |
|
|
|
|
|
|
|
in the parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Usage: eq=1h30m |
|
|
|
|
|
|
|
|
|
|
|
Not Equal |
|
|
|
Not Equal |
|
|
|
|
|
|
|
|
|
|
|
For strings & numbers, ne will ensure that the value is not |
|
|
|
For strings & numbers, ne will ensure that the value is not |
|
|
|
equal to the parameter given. For slices, arrays, and maps, |
|
|
|
equal to the parameter given. For slices, arrays, and maps, |
|
|
|
validates the number of items. |
|
|
|
validates the number of items. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #1 |
|
|
|
|
|
|
|
|
|
|
|
Usage: ne=10 |
|
|
|
Usage: ne=10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #2 (time.Duration) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For time.Duration, ne will ensure that the value is not equal to the duration |
|
|
|
|
|
|
|
given in the parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Usage: ne=1h30m |
|
|
|
|
|
|
|
|
|
|
|
One Of |
|
|
|
One Of |
|
|
|
|
|
|
|
|
|
|
|
For strings, ints, and uints, oneof will ensure that the value |
|
|
|
For strings, ints, and uints, oneof will ensure that the value |
|
|
@ -386,11 +431,17 @@ For time.Time ensures the time value is greater than time.Now.UTC(). |
|
|
|
|
|
|
|
|
|
|
|
Usage: gt |
|
|
|
Usage: gt |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #3 (time.Duration) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For time.Duration, gt will ensure that the value is greater than the duration |
|
|
|
|
|
|
|
given in the parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Usage: gt=1h30m |
|
|
|
|
|
|
|
|
|
|
|
Greater Than or Equal |
|
|
|
Greater Than or Equal |
|
|
|
|
|
|
|
|
|
|
|
Same as 'min' above. Kept both to make terminology with 'len' easier. |
|
|
|
Same as 'min' above. Kept both to make terminology with 'len' easier. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #1 |
|
|
|
Example #1 |
|
|
|
|
|
|
|
|
|
|
|
Usage: gte=10 |
|
|
|
Usage: gte=10 |
|
|
@ -401,6 +452,13 @@ For time.Time ensures the time value is greater than or equal to time.Now.UTC(). |
|
|
|
|
|
|
|
|
|
|
|
Usage: gte |
|
|
|
Usage: gte |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #3 (time.Duration) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For time.Duration, gte will ensure that the value is greater than or equal to |
|
|
|
|
|
|
|
the duration given in the parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Usage: gte=1h30m |
|
|
|
|
|
|
|
|
|
|
|
Less Than |
|
|
|
Less Than |
|
|
|
|
|
|
|
|
|
|
|
For numbers, this will ensure that the value is less than the parameter given. |
|
|
|
For numbers, this will ensure that the value is less than the parameter given. |
|
|
@ -412,10 +470,18 @@ Example #1 |
|
|
|
Usage: lt=10 |
|
|
|
Usage: lt=10 |
|
|
|
|
|
|
|
|
|
|
|
Example #2 (time.Time) |
|
|
|
Example #2 (time.Time) |
|
|
|
|
|
|
|
|
|
|
|
For time.Time ensures the time value is less than time.Now.UTC(). |
|
|
|
For time.Time ensures the time value is less than time.Now.UTC(). |
|
|
|
|
|
|
|
|
|
|
|
Usage: lt |
|
|
|
Usage: lt |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #3 (time.Duration) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For time.Duration, lt will ensure that the value is less than the duration given |
|
|
|
|
|
|
|
in the parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Usage: lt=1h30m |
|
|
|
|
|
|
|
|
|
|
|
Less Than or Equal |
|
|
|
Less Than or Equal |
|
|
|
|
|
|
|
|
|
|
|
Same as 'max' above. Kept both to make terminology with 'len' easier. |
|
|
|
Same as 'max' above. Kept both to make terminology with 'len' easier. |
|
|
@ -430,6 +496,13 @@ For time.Time ensures the time value is less than or equal to time.Now.UTC(). |
|
|
|
|
|
|
|
|
|
|
|
Usage: lte |
|
|
|
Usage: lte |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example #3 (time.Duration) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For time.Duration, lte will ensure that the value is less than or equal to the |
|
|
|
|
|
|
|
duration given in the parameter. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Usage: lte=1h30m |
|
|
|
|
|
|
|
|
|
|
|
Field Equals Another Field |
|
|
|
Field Equals Another Field |
|
|
|
|
|
|
|
|
|
|
|
This will validate the field value against another fields value either within |
|
|
|
This will validate the field value against another fields value either within |
|
|
@ -476,9 +549,9 @@ relative to the top level struct. |
|
|
|
|
|
|
|
|
|
|
|
Field Greater Than Another Field |
|
|
|
Field Greater Than Another Field |
|
|
|
|
|
|
|
|
|
|
|
Only valid for Numbers and time.Time types, this will validate the field value |
|
|
|
Only valid for Numbers, time.Duration and time.Time types, this will validate |
|
|
|
against another fields value either within a struct or passed in field. |
|
|
|
the field value against another fields value either within a struct or passed in |
|
|
|
usage examples are for validation of a Start and End date: |
|
|
|
field. usage examples are for validation of a Start and End date: |
|
|
|
|
|
|
|
|
|
|
|
Example #1: |
|
|
|
Example #1: |
|
|
|
|
|
|
|
|
|
|
@ -490,7 +563,6 @@ Example #2: |
|
|
|
// Validating by field:
|
|
|
|
// Validating by field:
|
|
|
|
validate.VarWithValue(start, end, "gtfield") |
|
|
|
validate.VarWithValue(start, end, "gtfield") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Field Greater Than Another Relative Field |
|
|
|
Field Greater Than Another Relative Field |
|
|
|
|
|
|
|
|
|
|
|
This does the same as gtfield except that it validates the field provided |
|
|
|
This does the same as gtfield except that it validates the field provided |
|
|
@ -500,9 +572,9 @@ relative to the top level struct. |
|
|
|
|
|
|
|
|
|
|
|
Field Greater Than or Equal To Another Field |
|
|
|
Field Greater Than or Equal To Another Field |
|
|
|
|
|
|
|
|
|
|
|
Only valid for Numbers and time.Time types, this will validate the field value |
|
|
|
Only valid for Numbers, time.Duration and time.Time types, this will validate |
|
|
|
against another fields value either within a struct or passed in field. |
|
|
|
the field value against another fields value either within a struct or passed in |
|
|
|
usage examples are for validation of a Start and End date: |
|
|
|
field. usage examples are for validation of a Start and End date: |
|
|
|
|
|
|
|
|
|
|
|
Example #1: |
|
|
|
Example #1: |
|
|
|
|
|
|
|
|
|
|
@ -523,9 +595,9 @@ to the top level struct. |
|
|
|
|
|
|
|
|
|
|
|
Less Than Another Field |
|
|
|
Less Than Another Field |
|
|
|
|
|
|
|
|
|
|
|
Only valid for Numbers and time.Time types, this will validate the field value |
|
|
|
Only valid for Numbers, time.Duration and time.Time types, this will validate |
|
|
|
against another fields value either within a struct or passed in field. |
|
|
|
the field value against another fields value either within a struct or passed in |
|
|
|
usage examples are for validation of a Start and End date: |
|
|
|
field. usage examples are for validation of a Start and End date: |
|
|
|
|
|
|
|
|
|
|
|
Example #1: |
|
|
|
Example #1: |
|
|
|
|
|
|
|
|
|
|
@ -546,9 +618,9 @@ to the top level struct. |
|
|
|
|
|
|
|
|
|
|
|
Less Than or Equal To Another Field |
|
|
|
Less Than or Equal To Another Field |
|
|
|
|
|
|
|
|
|
|
|
Only valid for Numbers and time.Time types, this will validate the field value |
|
|
|
Only valid for Numbers, time.Duration and time.Time types, this will validate |
|
|
|
against another fields value either within a struct or passed in field. |
|
|
|
the field value against another fields value either within a struct or passed in |
|
|
|
usage examples are for validation of a Start and End date: |
|
|
|
field. usage examples are for validation of a Start and End date: |
|
|
|
|
|
|
|
|
|
|
|
Example #1: |
|
|
|
Example #1: |
|
|
|
|
|
|
|
|
|
|
|