Go Validation Rule Index
All validators provide Not(), Or(), and OrElse(). Most rule methods also
accept an optional custom message template as their last argument.
String and StringP
Section titled “String and StringP”- Equality and ordering:
EqualTo,GreaterThan,GreaterOrEqualTo,LessThan,LessOrEqualTo,Between - Presence:
Empty,Blank; pointer forms also haveEmptyOrNil,BlankOrNil, andNil - Length in bytes:
MaxBytes,MinBytes,ByteLength,ByteLengthBetween - Length in runes:
MaxLength,MinLength,Length,LengthBetween - Other:
InSlice,MatchingTo,Passing
Deprecated string length aliases kept until v1.0: OfByteLength,
OfByteLengthBetween, OfLength, and OfLengthBetween.
Numeric families
Section titled “Numeric families”Use Int/IntP for every signed integer width, Uint/UintP for every
unsigned integer width, and Float/FloatP for both floating-point widths.
The width-specific numeric constructors are deprecated aliases. Rune and
Byte remain available for values with those semantics.
- Common:
EqualTo,GreaterThan,GreaterOrEqualTo,LessThan,LessOrEqualTo,Between,Zero,InSlice,Passing - Signed integers:
Positive,Negative - Floats:
Positive,Negative,NaN,Infinite,Finite - Pointer variants:
Nil,ZeroOrNil
Boolean
Section titled “Boolean”EqualTo, True, False, InSlice, Passing; pointer forms also provide
Nil and FalseOrNil.
EqualTo, After, AfterOrEqualTo, Before, BeforeOrEqualTo, Between,
Zero, InSlice, Passing; the pointer form also provides Nil and
NilOrZero.
Comparable
Section titled “Comparable”EqualTo, InSlice, and Passing; the pointer form also provides Nil.
Comparable validators do not provide ordering methods.
Typed and Any
Section titled “Typed and Any”Typed:Passing,NilAny:EqualTo,Passing,Nil
The github.com/cohesivestack/valgo/is package also exposes these rules as
standalone boolean functions. See Stateless Predicates.