valid

package
v2.0.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Formats = map[string]string{
	"alpha":               "^[a-zA-Z]+$",
	"alphaNumeric":        "^[a-zA-Z0-9]+$",
	"alphaUnicode":        "^[\\p{L}]+$",
	"alphaUnicodeNumeric": "^[\\p{L}\\p{N}]+$",
	"numeric":             "^[-+]?[0-9]+(?:\\.[0-9]+)?$",
	"number":              "^[0-9]+$",
	"email":               "^(?:(?:(?:(?:[a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+(?:\\.([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+)*)|(?:(?:\\x22)(?:(?:(?:(?:\\x20|\\x09)*(?:\\x0d\\x0a))?(?:\\x20|\\x09)+)?(?:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}]))))*(?:(?:(?:\\x20|\\x09)*(?:\\x0d\\x0a))?(\\x20|\\x09)+)?(?:\\x22))))@(?:(?:(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])(?:[a-zA-Z]|\\d|-|\\.|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.)+(?:(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])(?:[a-zA-Z]|\\d|-|\\.|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.?$",
	"uuid3":               "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$",
	"uuid4":               "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
	"uuid5":               "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
	"ulid":                "^[A-HJKMNP-TV-Z0-9]{26}$",
}
View Source
var Validators = map[string]qcode.Validator{
	"format": {
		Description: "Value must be of a format, eg: email, uuid",
		Types:       []graph.ParserType{graph.NodeLabel, graph.NodeStr},
		Type:        formatsEnum,
		NewFn:       format,
	},
	"required": {
		Description: "Variable is required",
		Types:       []graph.ParserType{graph.NodeBool},
		Type:        "Boolean",
		NewFn:       required,
	},
	"requiredIf": {
		Description: "Variable is required if another variable equals a value",
		Types:       []graph.ParserType{graph.NodeObj},
		NewFn:       requiredIf,
	},
	"requiredUnless": {
		Description: "Variable is required unless another variable equals a value",
		Types:       []graph.ParserType{graph.NodeObj},
		NewFn:       requiredUnless,
	},
	"requiredWith": {
		Description: "Variable is required if one of a list of other variables exist",
		Types:       []graph.ParserType{graph.NodeList, graph.NodeStr},
		Type:        "String",
		List:        true,
		NewFn:       requiredWith,
	},
	"requiredWithAll": {
		Description: "Variable is required if all of a list of other variables exist",
		Types:       []graph.ParserType{graph.NodeList, graph.NodeStr},
		Type:        "String",
		List:        true,
		NewFn:       requiredWithAll,
	},
	"requiredWithout": {
		Description: "Variable is required if one of a list of other variables does not exist",
		Types:       []graph.ParserType{graph.NodeList, graph.NodeStr},
		Type:        "String",
		List:        true,
		NewFn:       requiredWithout,
	},
	"requiredWithoutAll": {
		Description: "Variable is required if none of a list of other variables exist",
		Types:       []graph.ParserType{graph.NodeList, graph.NodeStr},
		Type:        "String",
		List:        true,
		NewFn:       requiredWithoutAll,
	},
	"max": {
		Description: "Maximum value a variable can be",
		Types:       []graph.ParserType{graph.NodeStr, graph.NodeNum},
		Type:        "Int",
		NewFn:       max,
	},
	"min": {
		Description: "Minimum value a variable can be",
		Types:       []graph.ParserType{graph.NodeStr, graph.NodeNum},
		Type:        "Int",
		NewFn:       min,
	},
	"equals": {
		Description: "Variable equals a value",
		Types:       []graph.ParserType{graph.NodeStr, graph.NodeNum},
		Type:        "String",
		NewFn:       equals,
	},
	"notEquals": {
		Description: "Variable does not equal a value",
		Types:       []graph.ParserType{graph.NodeStr, graph.NodeNum},
		Type:        "String",
		NewFn:       notEquals,
	},
	"oneOf": {
		Description: "Variable equals one of the following values",
		Types: []graph.ParserType{
			graph.NodeList, graph.NodeNum, graph.NodeList, graph.NodeStr,
		},
		Type:  "String",
		List:  true,
		NewFn: oneOf,
	},
	"greaterThan": {
		Description: "Variable is greater than a value",
		Types:       []graph.ParserType{graph.NodeNum},
		Type:        "Int",
		NewFn:       greaterThan,
	},
	"greaterThanOrEquals": {
		Description: "Variable is greater than or equal to a value",
		Types:       []graph.ParserType{graph.NodeStr, graph.NodeNum},
		Type:        "Int",
		NewFn:       greaterThanOrEquals,
	},
	"lessThan": {
		Description: "Variable is less than a value",
		Types:       []graph.ParserType{graph.NodeStr, graph.NodeNum},
		Type:        "Int",
		NewFn:       lessThan,
	},
	"lessThanOrEquals": {
		Description: "Variable is less than or equal to a value",
		Types:       []graph.ParserType{graph.NodeStr, graph.NodeNum},
		Type:        "Int",
		NewFn:       lessThanOrEquals,
	},
	"equalsField": {
		Description: "Variable equals the value of another variable",
		Types:       []graph.ParserType{graph.NodeStr},
		Type:        "Int",
		NewFn:       equalsField,
	},
	"notEqualsField": {
		Description: "Variable does not equal the value of another variable",
		Types:       []graph.ParserType{graph.NodeStr},
		Type:        "Int",
		NewFn:       notEqualsField,
	},
	"greaterThanField": {
		Description: "Variable is greater than the value of another variable",
		Types:       []graph.ParserType{graph.NodeStr},
		Type:        "String",
		NewFn:       greaterThanField,
	},
	"greaterThanOrEqualsField": {
		Description: "Variable is greater than or equals the value of another variable",
		Types:       []graph.ParserType{graph.NodeStr},
		Type:        "String",
		NewFn:       greaterThanOrEqualsField,
	},
	"lessThanField": {
		Description: "Variable is less than the value of another variable",
		Types:       []graph.ParserType{graph.NodeStr},
		Type:        "String",
		NewFn:       lessThanField,
	},
	"lessThanOrEqualsField": {
		Description: "Variable is less than or equals the value of another variable",
		Types:       []graph.ParserType{graph.NodeStr},
		Type:        "String",
		NewFn:       lessThanOrEqualsField,
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL