Documentation ¶
Index ¶
- Constants
- Variables
- func Align(name string, a interface{}) align
- func Process(name string, apply ...Apply) processor
- func ToCamelCase(s string) string
- func ToPascalCase(s string) string
- func ToSnakeCase(s string) string
- func Validate(name string, matches ...Match) validator
- type Apply
- type Belief
- type InvalidUnmarshalError
- type Match
- func MustEquals(s string) Match
- func MustHasDigit() Match
- func MustHasLetter() Match
- func MustHasLower() Match
- func MustHasString(s string) Match
- func MustHasSuffix(s string) Match
- func MustHasSymbol() Match
- func MustHasUpper() Match
- func MustIn(s []string) Match
- func MustIsChinaMobile() Match
- func MustIsChinese() Match
- func MustIsDigit() Match
- func MustIsEmail() Match
- func MustIsIP() Match
- func MustIsJSON() Match
- func MustIsLetter() Match
- func MustIsLetterOrDigit() Match
- func MustIsLower() Match
- func MustIsLowerOrDigit() Match
- func MustIsNumberValue() Match
- func MustIsSQLObject() Match
- func MustIsURL() Match
- func MustIsUUID() Match
- func MustIsUpper() Match
- func MustIsUpperOrDigit() Match
- func MustNotNil() Match
- func MustString() Match
- func MustTrue() Match
- type Type
- func (t Type) Equals(other Type) bool
- func (t Type) FriendlyName() string
- func (t Type) GetStringMapType(key string) (Type, error)
- func (t Type) GoString() string
- func (t Type) IsMapType() bool
- func (t Type) IsPrimitiveType() bool
- func (t Type) Len() int
- func (t Type) UpdateAttrType(ty map[string]Type) error
- type Value
- func BoolVal(v bool) Value
- func Float32Val(v float32) Value
- func Float64Val(v float64) Value
- func HttpRequestBodyVal(req *http.Request) Value
- func HttpRequestFormVal(req *http.Request) Value
- func HttpRequestQueryVal(req *http.Request) Value
- func Int16Val(v int16) Value
- func Int32Val(v int32) Value
- func Int64Val(v int64) Value
- func Int8Val(v int8) Value
- func IntVal(v int) Value
- func MapStringVal(vals map[string]Value) Value
- func MapStringValEmpty() Value
- func NullVal(t Type) Value
- func ParseFloat64Val(s string) (Value, error)
- func StringVal(v string) Value
- func Uint16Val(v uint16) Value
- func Uint32Val(v uint32) Value
- func Uint64Val(v uint64) Value
- func Uint8Val(v uint8) Value
- func UintVal(v uint) Value
- func (val Value) Align(a align) error
- func (val Value) Aligns(aligns ...align) error
- func (val Value) Converter() converter
- func (val Value) Equals(v Value) bool
- func (val Value) GetError() error
- func (val Value) GetErrorResponseWriter(resp http.ResponseWriter) error
- func (val Value) GetMapValue(name string) Value
- func (val Value) IsMapValue() bool
- func (val Value) IsNull() bool
- func (val Value) IsPrimitiveValue() bool
- func (val Value) Processor(name string, apply ...Apply) processor
- func (val Value) Processors(ps ...processor) processors
- func (val Value) SetMapValue(name string, value Value) Value
- func (val Value) String() string
- func (val Value) StringProcessor() stringProcessor
- func (val Value) Type() Type
- func (val Value) UnMarshal(v interface{}) error
- func (val Value) Validate(name string, match ...Match) validator
- func (val Value) Validates(validates ...validator) validators
- func (val Value) Value() Value
Constants ¶
const ( FmtMustNotNil = "%s filed value must is not nil" FmtMustTrue = "%s filed value must is true" FmtMustHasSuffix = "%s filed value must has %s suffix" FmtMustString = "%s filed value must is a string type" FmtMustHasString = "%s filed value must has %s string value" FmtMustHasSymbol = "%s filed value must has symbol" FmtMustHasDigit = "%s filed value must has digit" FmtMustHasLetter = "%s filed value must has letter" FmtMustHasLower = "%s filed value must has lower" FmtMustHasUpper = "%s filed value must has upper" FmtMustIn = "%s filed value must in %value upper" FmtMustEquals = "%s filed value must equals %s" FmtMustIsLower = "%s filed value must is lower" FmtMustIsUpper = "%s filed value must is upper" FmtMustIsLetter = "%s filed value must is letter" FmtMustIsDigit = "%s filed value must is digit" FmtMustIsLowerOrDigit = "%s filed value must is lower or digit" FmtMustIsUpperOrDigit = "%s filed value must is upper or digit" FmtMustIsLetterOrDigit = "%s filed value must is letter or digit" FmtMustIsChinese = "%s filed value must is chinese" FmtMustIsUUID = "%s filed value must is uuid" FmtMustIsSQLObject = "%s filed value must is sql " FmtMustIsIp = "%s filed value must is ip " FmtMustIsNumber = "%s filed value must is number type" )
Variables ¶
var ConvertError = errors.New("This type conversion is not supported")
var NilVal = Value{ // contains filtered or unexported fields }
Functions ¶
func ToCamelCase ¶
func ToPascalCase ¶
func ToSnakeCase ¶
Types ¶
type Apply ¶
type Apply func(val *processor) error
func Base64StdEncode ¶
func Base64StdEncode() Apply
func RemoveSpace ¶
func RemoveSpace() Apply
type InvalidUnmarshalError ¶
An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)
func (*InvalidUnmarshalError) Error ¶
func (e *InvalidUnmarshalError) Error() string
type Match ¶
type Match func(val *validator) error
func MustEquals ¶
func MustHasDigit ¶
func MustHasDigit() Match
func MustHasLetter ¶
func MustHasLetter() Match
func MustHasLower ¶
func MustHasLower() Match
func MustHasString ¶
func MustHasSuffix ¶
func MustHasSymbol ¶
func MustHasSymbol() Match
func MustHasUpper ¶
func MustHasUpper() Match
func MustIsChinaMobile ¶
func MustIsChinaMobile() Match
func MustIsChinese ¶
func MustIsChinese() Match
func MustIsDigit ¶
func MustIsDigit() Match
func MustIsEmail ¶
func MustIsEmail() Match
func MustIsJSON ¶
func MustIsJSON() Match
func MustIsLetter ¶
func MustIsLetter() Match
func MustIsLetterOrDigit ¶
func MustIsLetterOrDigit() Match
func MustIsLower ¶
func MustIsLower() Match
func MustIsLowerOrDigit ¶
func MustIsLowerOrDigit() Match
func MustIsNumberValue ¶
func MustIsNumberValue() Match
func MustIsSQLObject ¶
func MustIsSQLObject() Match
func MustIsUUID ¶
func MustIsUUID() Match
func MustIsUpper ¶
func MustIsUpper() Match
func MustIsUpperOrDigit ¶
func MustIsUpperOrDigit() Match
func MustNotNil ¶
func MustNotNil() Match
func MustString ¶
func MustString() Match
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type represents value types within the type system.
This is a closed interface type, meaning that only the concrete implementations provided within this package are considered valid.
var Bool Type
var Float32 Type
var Float64 Type
var Int Type
var Int16 Type
var Int32 Type
var Int64 Type
var Int8 Type
var String Type
var Uint Type
var Uint16 Type
var Uint32 Type
var Uint64 Type
var Uint8 Type
func StringMapType ¶
func (Type) FriendlyName ¶
func (Type) IsPrimitiveType ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
var False Value
var NegativeInfinity Value
var PositiveInfinity Value
var True Value
var Zero Value
func Float32Val ¶
func Float64Val ¶
func HttpRequestBodyVal ¶
func HttpRequestFormVal ¶
func HttpRequestQueryVal ¶
func MapStringVal ¶
func MapStringValEmpty ¶
func MapStringValEmpty() Value
func NullVal ¶
NullVal returns a null value of the given type. A null can be created of any type, but operations on such values will always panic. Calling applications are encouraged to use nulls only sparingly, particularly when user-provided expressions are to be evaluated, since the precence of nulls creates a much higher chance of evaluation errors that can't be caught by a type checker.
func ParseFloat64Val ¶
ParseNumberVal returns a Value of type number produced by parsing the given string as a decimal real number. To ensure that two identical strings will always produce an equal number, always use this function to derive a number from a string; it will ensure that the precision and rounding mode for the internal big decimal is configured in a consistent way.
If the given string cannot be parsed as a number, the returned error has the message "a number is required", making it suitable to return to an end-user to signal a type conversion error.
If the given string contains a number that becomes a recurring fraction when expressed in binary then it will be truncated to have a 512-bit mantissa. Note that this is a higher precision than that of a float64, so coverting the same decimal number first to float64 and then calling NumberFloatVal will not produce an equal result; the conversion first to float64 will round the mantissa to fewer than 512 bits.
func StringVal ¶
StringVal returns a Value of type String whose internal value is the given string.
Strings must be UTF-8 encoded sequences of valid unicode codepoints, and they are NFC-normalized on entry into the world of cty values.
If the given string is not valid UTF-8 then behavior of string operations is undefined.
func (Value) GetErrorResponseWriter ¶
func (val Value) GetErrorResponseWriter(resp http.ResponseWriter) error
func (Value) GetMapValue ¶
func (Value) IsMapValue ¶
func (Value) IsPrimitiveValue ¶
func (Value) Processors ¶
func (val Value) Processors(ps ...processor) processors
func (Value) StringProcessor ¶
func (val Value) StringProcessor() stringProcessor