Documentation ¶
Index ¶
- Variables
- type EnumValidator
- type JsonFormatValidator
- func (validator JsonFormatValidator) CompileTerm(_ *ls.CompileContext, target ls.CompilablePropertyContainer, term string, ...) error
- func (validator JsonFormatValidator) ValidateNode(docNode, schemaNode *lpg.Node) error
- func (validator JsonFormatValidator) ValidateValue(value *string, schemaNode *lpg.Node) error
- type PatternValidator
- func (validator PatternValidator) CompileTerm(_ *ls.CompileContext, target ls.CompilablePropertyContainer, term string, ...) error
- func (validator PatternValidator) ValidateNode(docNode, schemaNode *lpg.Node) error
- func (validator PatternValidator) ValidateValue(value *string, schemaNode *lpg.Node) error
- type RequiredValidator
- func (validator RequiredValidator) CompileTerm(_ *ls.CompileContext, target ls.CompilablePropertyContainer, term string, ...) error
- func (validator RequiredValidator) Validate(docNode, schemaNode *lpg.Node) error
- func (validator RequiredValidator) ValidateNode(docNode, schemaNode *lpg.Node) error
- func (validator RequiredValidator) ValidateValue(value *string, schemaNode *lpg.Node) error
Constants ¶
This section is empty.
Variables ¶
var ConstTerm = ls.NewTerm(ls.LS, "validation/const").SetComposition(ls.OverrideComposition).SetTags(ls.ValidationTag, ls.SchemaElementTag).SetMetadata(struct { EnumValidator }{ EnumValidator{}, }).Register
ConstTerm is used for constant value validator
Const is declared as a string value:
{ @id: attrId, @type: Value, validation/const: "a" }
Const is syntactic sugar for enum with a single value
var EnumTerm = ls.NewTerm(ls.LS, "validation/enumeration").SetComposition(ls.OverrideComposition).SetTags(ls.ValidationTag, ls.SchemaElementTag).SetMetadata(struct { EnumValidator }{ EnumValidator{}, }).Register()
EnumTerm is used for enumeration validator
Enumeration is declared as a string slice:
{ @id: attrId, @type: Value, validation/enumeration: ["a","b","c"] }
var JsonFormatTerm = ls.NewTerm(ls.LS, "validation/json/format").SetComposition(ls.OverrideComposition).SetTags(ls.ValidationTag, ls.SchemaElementTag).SetMetadata(struct { JsonFormatValidator }{ JsonFormatValidator{}, }).Register()
JsonFormatTerm validates if the value matches one of the json format implementations
var PatternTerm = ls.NewTerm(ls.LS, "validation/pattern").SetComposition(ls.OverrideComposition).SetTags(ls.ValidationTag, ls.SchemaElementTag).SetMetadata(struct { PatternValidator }{ PatternValidator{}, }).Register()
PatternTerm validates against a regex
var RequiredTerm = ls.NewTerm(ls.LS, "validation/required").SetComposition(ls.OverrideComposition).SetTags(ls.ValidationTag, ls.SchemaElementTag).SetMetadata(struct { RequiredValidator }{ RequiredValidator{}, }).Register()
RequiredTerm validates if a required properties exist.
{ @id: attrId validation/required: true }
Functions ¶
This section is empty.
Types ¶
type EnumValidator ¶
type EnumValidator struct{}
EnumValidator checks if a value is equal to one of the given options.
func (EnumValidator) ValidateNode ¶
func (validator EnumValidator) ValidateNode(docNode, schemaNode *lpg.Node) error
ValidateNode validates the node value if it is non-nil
func (EnumValidator) ValidateValue ¶
func (validator EnumValidator) ValidateValue(value *string, schemaNode *lpg.Node) error
type JsonFormatValidator ¶
type JsonFormatValidator struct{}
JsonFormatValidator checks if the input value matches a given format
func (JsonFormatValidator) CompileTerm ¶
func (validator JsonFormatValidator) CompileTerm(_ *ls.CompileContext, target ls.CompilablePropertyContainer, term string, value *ls.PropertyValue) error
func (JsonFormatValidator) ValidateNode ¶
func (validator JsonFormatValidator) ValidateNode(docNode, schemaNode *lpg.Node) error
ValidateNode validates the node value if it is non-nil
func (JsonFormatValidator) ValidateValue ¶
func (validator JsonFormatValidator) ValidateValue(value *string, schemaNode *lpg.Node) error
ValidateValue checks if the value matches the format
type PatternValidator ¶
type PatternValidator struct{}
PatternValidator validates a string value against a regex
func (PatternValidator) CompileTerm ¶
func (validator PatternValidator) CompileTerm(_ *ls.CompileContext, target ls.CompilablePropertyContainer, term string, value *ls.PropertyValue) error
Compile the pattern
func (PatternValidator) ValidateNode ¶
func (validator PatternValidator) ValidateNode(docNode, schemaNode *lpg.Node) error
Validate validates the node value if it is non-nil
func (PatternValidator) ValidateValue ¶
func (validator PatternValidator) ValidateValue(value *string, schemaNode *lpg.Node) error
ValidateValue validates the value
type RequiredValidator ¶
type RequiredValidator struct{}
RequiredValidator validates if a required value exists
func (RequiredValidator) CompileTerm ¶
func (validator RequiredValidator) CompileTerm(_ *ls.CompileContext, target ls.CompilablePropertyContainer, term string, value *ls.PropertyValue) error
CompileTerm compiles the required properties array
func (RequiredValidator) Validate ¶
func (validator RequiredValidator) Validate(docNode, schemaNode *lpg.Node) error
Validate checks if value is nil. If value is nil and it is required, returns an error
func (RequiredValidator) ValidateNode ¶
func (validator RequiredValidator) ValidateNode(docNode, schemaNode *lpg.Node) error
ValidateNode checks if value is nil. If value is nil and it is required, returns an error
func (RequiredValidator) ValidateValue ¶
func (validator RequiredValidator) ValidateValue(value *string, schemaNode *lpg.Node) error
ValidateValue checks if value is nil. If value is nil and it is required, returns an error