Skip to content

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.

  • Equality and ordering: EqualTo, GreaterThan, GreaterOrEqualTo, LessThan, LessOrEqualTo, Between
  • Presence: Empty, Blank; pointer forms also have EmptyOrNil, BlankOrNil, and Nil
  • 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.

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

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.

EqualTo, InSlice, and Passing; the pointer form also provides Nil. Comparable validators do not provide ordering methods.

  • Typed: Passing, Nil
  • Any: EqualTo, Passing, Nil

The github.com/cohesivestack/valgo/is package also exposes these rules as standalone boolean functions. See Stateless Predicates.