You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This rule checks the field under validation is a datetime value after the given datetime. The after rule accepts two parameters, otherField and timeZone. The otherField is a mandatory parameter that specifies the field to compare the current field value.
Note that when using this rule, the field under validation must pass the datetime rule, and the otherField must be present and also pass the datetime rule.
The default value for the time zone parameter is UTC.
Translation
Key
Params
validation.after
field, otherField
Param name
Description
field
The field under validation.
OtherField
The other field that the current field is compare with.
After Or Equal: afterOrEqual:otherField[,timeZone]
This rule checks the field under validation is a datetime value after or equal to the given datetime. The afterOrEqual rule accepts two parameters, otherField and timeZone. The otherField is a mandatory parameter that specifies the field to compare the current field value.
Note that when using this rule, the field under validation must pass the datetime rule, and the otherField must be present and also pass the datetime rule.
This rule checks the field under validation is a datetime value before the given datetime. The before rule accepts two parameters, otherField and timeZone. The otherField is a mandatory parameter that specifies the field to compare the current field value.
Note that when using this rule, the field under validation must pass the datetime rule, and the otherField must be present and also pass the datetime rule.
The default value for the time zone parameter is UTC.
Translation
Key
Params
validation.before
field, otherField
Param name
Description
field
The field under validation.
OtherField
The other field that the current field is compare with.
Before Or Equal: beforeOrEqual:otherField[,timeZone]
This rule checks the field under validation is a datetime value before the given datetime. The beforeOrEqual rule accepts two parameters, otherField and timeZone. The otherField is a mandatory parameter that specifies the field to compare the current field value.
Note that when using this rule, the field under validation must pass the datetime rule, and the otherField must be present and also pass the datetime rule.
The default value for the time zone parameter is UTC.
Translation
Key
Params
validation.before_or_equal
field, otherField
Param name
Description
field
The field under validation.
OtherField
The other field that the current field is compare with.
Between: between:min,max
This rule acts a little differently based on the type of field value.
If the value is numeric, the rule will check the value is between the given min and max.
If the value is a string, slice, array, or map, the rule will check the length of the value is between the given min and max.
Otherwise, the rule checks nothing.
rulesMap:= validation.RulesMap{
"age": {"between:18,30"}, // assume age is an integer value"score": {"between:8.5,10"}, // assume score is a float value"title": {"between:5,50"}, // assume title is a string value"skills": {"between:2,5"}, // assume skills is a slice of strings
}
The between rule only checks the condition when the field under validation is present.
Translation
Key
Params
validation.between
field, min, max
Param name
Description
field
The field under validation.
min
The minimum value set in the rule.
max
The maximum value set in the rule.
Boolean: boolean
This rule checks the field under validation has a boolean value.
This rule acts a little differently based on the type of field value.
If the value is numeric, the rule will check the value is greater than given value.
If the value is a string, slice, array, or map, the rule will check the length of the value is greater than given value.
Otherwise, the rule checks nothing.
rulesMap:= validation.RulesMap{
"age": {"gt:18"}, // assume age is an integer value"score": {"gt:8.5"}, // assume score is a float value"title": {"gt:5"}, // assume title is a string value"skills": {"gt:2"}, // assume skills is a slice of strings
}
Translation
Key
Params
validation.gt
field, value
Param name
Description
field
The field under validation.
value
The min value set in rule.
Greater Than or Equal: gte:value
This rule acts a little differently based on the type of field value.
If the value is numeric, the rule will check the value is greater than or equal to given value.
If the value is a string, slice, array, or map, the rule will check the length of the value is greater than or equal to given value.
Otherwise, the rule checks nothing.
rulesMap:= validation.RulesMap{
"age": {"gte:18"}, // assume age is an integer value"score": {"gte:8.5"}, // assume score is a float value"title": {"gte:5"}, // assume title is a string value"skills": {"gte:2"}, // assume skills is a slice of strings
}
Translation
Key
Params
validation.gte
field, value
Param name
Description
field
The field under validation.
value
The min value set in rule.
In: in:value1,value2[,value3,...]
This rule check the field under validation exists in one of the given options.
This rule acts a little differently based on the type of field value.
If the value is numeric, the rule will check the value is less than given value.
If the value is a string, slice, array, or map, the rule will check the length of the value is less than given value.
Otherwise, the rule checks nothing.
rulesMap:= validation.RulesMap{
"age": {"lt:18"}, // assume age is an integer value"score": {"lt:8.5"}, // assume score is a float value"title": {"lt:5"}, // assume title is a string value"skills": {"lt:2"}, // assume skills is a slice of strings
}
Translation
Key
Params
validation.lt
field, value
Param name
Description
field
The field under validation.
value
The max value set in rule.
Less Than or Equal: lte:value
This rule acts a little differently based on the type of field value.
If the value is numeric, the rule will check the value is less than or equal to given value.
If the value is a string, slice, array, or map, the rule will check the length of the value is less than or equal to given value.
Otherwise, the rule checks nothing.
rulesMap:= validation.RulesMap{
"age": {"lte:18"}, // assume age is an integer value"score": {"lte:8.5"}, // assume score is a float value"title": {"lte:5"}, // assume title is a string value"skills": {"lte:2"}, // assume skills is a slice of strings
}
Translation
Key
Params
validation.lte
field, value
Param name
Description
field
The field under validation.
value
The max value set in rule.
Max: max:value
This rule checks the field under validation value be less than given value.
This rule check the field under validation exists if the given condition is true.
The condition is consists of another field name and a value. If the value of the other field is equal to
the given value, the field under validation is required.
Note that the only supported type for value parameter is string.
This rule check the field under validation exists unless the given condition is true.
The condition is consists of another field name and a value. Unless the value of the other field is equal to
the given value, the field under validation is required.
Note that the only supported type for value parameter is string.