# README
Validate
Package validate
contains validation helpers.
struct field tag based validation helpers
Tag | Description/Constraints | Supported Types | Syntax Examples | Notes |
---|---|---|---|---|
min | Value 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. |
max | Value must be less than or equal to the maximum value specified in the tag. | Numerical, comparable types | max:"25" | Upper-bound check for compatible types (same as min ). |
range | Value must fall within any of the provided ranges (OR logic between comma-separated values). | String, int/uint/float, rune | range:"..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. |
char | Every character in the string must fall within specified character ranges (e.g., letters, symbols). | String, rune | char:"a-z,A-Z" char:"0-9" | Supports open-ended ranges like "A-" (characters from A to end of alphabet). |
length | Constrain the length of the value (len(value) must match the condition). | string, slice, map, channel | length:"<=10" length:"5..10" length"5" len:"5" | Alias: Use len:"..." for the same effect. Works with types that have a defined len() . |
enum | Limits 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. |
regexp | Match the value agaist a regular expression. | string, []byte | regexp:"^foo$" rgx:"^foo$" match:"^foo$" | Expects Perl syntax regular expression. Aliases: rgx , match . |