123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- package binding
- const (
-
- ERR_CONTENT_TYPE = "ContentTypeError"
- ERR_DESERIALIZATION = "DeserializationError"
- ERR_INTERGER_TYPE = "IntegerTypeError"
- ERR_BOOLEAN_TYPE = "BooleanTypeError"
- ERR_FLOAT_TYPE = "FloatTypeError"
-
- ERR_REQUIRED = "RequiredError"
- ERR_ALPHA_DASH = "AlphaDashError"
- ERR_ALPHA_DASH_DOT = "AlphaDashDotError"
- ERR_SIZE = "SizeError"
- ERR_MIN_SIZE = "MinSizeError"
- ERR_MAX_SIZE = "MaxSizeError"
- ERR_RANGE = "RangeError"
- ERR_EMAIL = "EmailError"
- ERR_URL = "UrlError"
- ERR_IN = "InError"
- ERR_NOT_INT = "NotInError"
- ERR_INCLUDE = "IncludeError"
- ERR_EXCLUDE = "ExcludeError"
- ERR_DEFAULT = "DefaultError"
- )
- type (
-
-
-
-
- Errors []Error
- Error struct {
-
-
-
-
-
- FieldNames []string `json:"fieldNames,omitempty"`
-
-
-
- Classification string `json:"classification,omitempty"`
-
-
-
-
-
- Message string `json:"message,omitempty"`
- }
- )
- func (e *Errors) Add(fieldNames []string, classification, message string) {
- *e = append(*e, Error{
- FieldNames: fieldNames,
- Classification: classification,
- Message: message,
- })
- }
- func (e *Errors) Len() int {
- return len(*e)
- }
- func (e *Errors) Has(class string) bool {
- for _, err := range *e {
- if err.Kind() == class {
- return true
- }
- }
- return false
- }
- func (e Error) Fields() []string {
- return e.FieldNames
- }
- func (e Error) Kind() string {
- return e.Classification
- }
- func (e Error) Error() string {
- return e.Message
- }
|