Documentation ¶
Overview ¶
Each Validator have at least two process methods, one for 'Parsing' and one for 'Validating'.
In 'Parsing' stage, we call validator as 'Creator', and it will be register to some 'Mgr' for caching.
Parsing ¶
There are common 'Rule DSL' below:
// simple @name // with parameters @name<param1> @name<param1,param2> // with ranges @name[from, to) @name[length] // with values @name{VALUE1,VALUE2,VALUE3} @name{%v} // with regexp @name/\d+/ // optional and default value @name? @name = value @name = 'some string value' // composes @map<@string[1,10],@string{A,B,C}> @map<@string[1,10],@string/\d+/>[0,10]
Then the parsed rule will be transform to special validators:
Validating ¶
We can create validator by 'Rule DSL', and also can configure them by validator struct field as conditions. Then call the method `Validate(v any) error` to do value validations.
Index ¶
- func Marshal(out any, options ...jsontext.Options) ([]byte, error)
- func MarshalEncode(enc *jsontext.Encoder, out any, options ...jsontext.Options) error
- func MarshalWrite(w io.Writer, out any, options ...jsontext.Options) error
- func Register(creator Creator)
- func Unmarshal(in []byte, out any, options ...jsontext.Options) error
- func UnmarshalDecode(dec *jsontext.Decoder, out any, options ...jsontext.Options) error
- func UnmarshalRead(r io.Reader, out any, options ...jsontext.Options) error
- type Creator
- type Option
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalEncode ¶
func UnmarshalDecode ¶
Types ¶
type Creator ¶
type Creator = internal.ValidatorProvider
type Option ¶
type Option = internal.ValidatorOption
Directories ¶
Path | Synopsis |
---|---|
Package errors GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
|
Package errors GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE |
Package internal GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
|
Package internal GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE |
rules
+gengo:runtimedoc=false
|
+gengo:runtimedoc=false |
Package validators GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
|
Package validators GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE |
Click to show internal directories.
Click to hide internal directories.