package
0.305.0
Repository: https://github.com/adamluzsi/frameless.git
Documentation: pkg.go.dev

# README

Validate

Package validate contains validation helpers.

struct field tag based validation helpers

TagDescription/ConstraintsSupported TypesSyntax ExamplesNotes
minValue must be greater than or equal to the minimum value specified in the tag.Numerical, comparable types (e.g., int, float)min:"10"Works with numerical and comparable types like integers and floats.
maxValue must be less than or equal to the maximum value specified in the tag.Numerical, comparable typesmax:"25"Upper-bound check for compatible types (same as min).
rangeValue must fall within any of the provided ranges (OR logic between comma-separated values).String, int/uint/float, runerange:"..10"
range:"a-z,A-Z"
range:"5..10"
- Open-ended formats: ..max → ≤ max; min.. → ≥ min.
- For strings: Lexical (range:"a..bb") or character ranges (range:"a-z,A-Z").
- Ranges are comma-separated and in OR logic.
charEvery character in the string must fall within specified character ranges (e.g., letters, symbols).String, runechar:"a-z,A-Z"
char:"0-9"
Supports open-ended ranges like "A-" (characters from A to end of alphabet).
lengthConstrain the length of the value (len(value) must match the condition).string, slice, map, channellength:"<=10"
length:"5..10"
length"5"
len:"5"
Alias: Use len:"..." for the same effect. Works with types that have a defined len().
enumLimits valid values to a predefined list of options.Any type (registered or representable)enum:"foo bar baz"
enum:"foo,bar,baz"
- Uses either enum.Register for registration or direct representation in the tag.
- Supports various types when registered.
regexpMatch the value agaist a regular expression.string, []byteregexp:"^foo$"
rgx:"^foo$"
match:"^foo$"
Expects Perl syntax regular expression.
Aliases: rgx, match.