Documentation
¶
Overview ¶
Int Validators
Index ¶
- Constants
- func Must(value int64, err error) int64
- func MustMultiple(values []int64, err error) []int64
- func Validate(value int64, rules ...ValidationRule) (int64, error)
- func ValidateFromString(src string, rules ...ValidationRule) (int64, error)
- func ValidateFromStringMultiple(srcs []string, rules ...ValidationRule) ([]int64, error)
- func ValidateMultiple(values []int64, rules ...ValidationRule) ([]int64, error)
- type ValidationRule
- func Between(min, max int64) ValidationRule
- func DefaultValue(defaultValue int64) ValidationRule
- func Mandatory() ValidationRule
- func Matches(matches ...int64) ValidationRule
- func Max(max int64) ValidationRule
- func Min(min int64) ValidationRule
- func Optional(rules ...ValidationRule) ValidationRule
- func OverrideErrorMsg(validationError vError.ValidationError, rules ...ValidationRule) ValidationRule
- func Step(step int64) ValidationRule
Constants ¶
View Source
const ( Type = "int" NotAnIntErrorFormat = "{{.value}} is not an integer." MandatoryErrorFormat = "Must not be left empty." MinErrorFormat = "Cannot be less than '{{.min}}'." MaxErrorFormat = "Cannot be more than '{{.max}}'." BetweenErrorFormat = "Must be between '{{.min}}' and '{{.max}}'." StepErrorFormat = "Must be in step of '{{.step}}'." MatchesErrorFormat = "Is not in the list, valid matches are '{{.matches|join \"and\"}}'." )
Variables ¶
This section is empty.
Functions ¶
func MustMultiple ¶
func ValidateFromString ¶
func ValidateFromString(src string, rules ...ValidationRule) (int64, error)
Convert to int64 and than validate.
func ValidateFromStringMultiple ¶
func ValidateFromStringMultiple(srcs []string, rules ...ValidationRule) ([]int64, error)
Convert to int64 and than validate. (Multiple)
func ValidateMultiple ¶
func ValidateMultiple(values []int64, rules ...ValidationRule) ([]int64, error)
Types ¶
type ValidationRule ¶
func DefaultValue ¶
func DefaultValue(defaultValue int64) ValidationRule
If the value is not set, set it to the default value.
Note: will only work while validating from string
func Mandatory ¶
func Mandatory() ValidationRule
Make sure value is set, if not set the rule return a validation error
Note: will only work while validating from string
func Matches ¶
func Matches(matches ...int64) ValidationRule
Check for matches, return error if matches is not found
func Optional ¶
func Optional(rules ...ValidationRule) ValidationRule
Optional Value, if value is not set, return nil, otherwise go though the validation rules.
Note: will only work while validating from string
func OverrideErrorMsg ¶
func OverrideErrorMsg(validationError vError.ValidationError, rules ...ValidationRule) ValidationRule
Override Error Message
func Step ¶
func Step(step int64) ValidationRule
Number of step, if value not within number of steps returns an error.
Click to show internal directories.
Click to hide internal directories.