diff --git a/RULES.md b/RULES.md index 19d6bc7..e83c43e 100644 --- a/RULES.md +++ b/RULES.md @@ -187,6 +187,18 @@ The field under validation must not be empty when it is present. This validator is almost equal to the `required` validator except that it allows nil values. +### `gt:field` + +The field under validation must be greater than the given field. +The two fields must be of the same type. +Strings, numerics, arrays, and files are evaluated using the same conventions as the size rule. + +### `gte:field` + +The field under validation must be greater than or equal to the given field or value. +The two fields must be of the same type. +Strings, numerics, arrays, and files are evaluated using the same conventions as the size rule. + ### `hex_color` The field under validation must contain a valid color value in [hexadecimal](https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color) format. @@ -211,6 +223,18 @@ The field under validation must be an IPv6 address. The field under validation must be a valid JSON `string` or `[]byte`. +### `lt:field` + +The field under validation must be less than the given field. +The two fields must be of the same type. +Strings, numerics, arrays, and files are evaluated using the same conventions as the size rule. + +### `lte:field` + +The field under validation must be less than or equal to the given field. +The two fields must be of the same type. +Strings, numerics, arrays, and files are evaluated using the same conventions as the size rule. + ### `lowercase` The field under validation must be lowercase. diff --git a/needle.go b/needle.go index 9435a90..64092fd 100644 --- a/needle.go +++ b/needle.go @@ -220,6 +220,16 @@ func (n *Needle) IsNumeric() bool { } } +// IsBool returns true if the type kind is a list +func (n *Needle) IsList() bool { + switch n.Kind() { + case reflect.Slice, reflect.Array: + return true + default: + return false + } +} + // HasLen returns true if the type kind supports the reflect.Len method func (n *Needle) HasLen() bool { switch n.Kind() { @@ -265,3 +275,37 @@ func (n *Needle) Date() (time.Time, ConvertStatus) { return time.Time{}, InvalidType } } + +// Float64 tries to convert the number to a float64 +func (n *Needle) Float64() (float64, bool) { + if !n.HasValue() { + return 0, false + } + + switch n.Kind() { + case reflect.Float32, reflect.Float64: + return n.Value.Float(), true + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return float64(n.Value.Int()), true + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return float64(n.Value.Uint()), true + } + + return 0, false +} + +// Int64 tries to convert the number to a int64 +func (n *Needle) Int64() (int64, bool) { + if !n.HasValue() { + return 0, false + } + + switch n.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return n.Value.Int(), true + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return int64(n.Value.Uint()), true + } + + return 0, false +} diff --git a/rules.go b/rules.go index c1f8ca3..b67ac04 100644 --- a/rules.go +++ b/rules.go @@ -74,10 +74,8 @@ func init() { // File RegisterValidator("filled", Filled) - - // Greater Than - // Greater Than Or Equal - + RegisterValidator("gt", Gt) + RegisterValidator("gte", Gte) RegisterValidator("hex_color", HexColor) // Image (File) @@ -91,10 +89,8 @@ func init() { RegisterValidator("ipv4", IPV4) RegisterValidator("ipv6", IPV6) RegisterValidator("json", JSON) - - // Less Than - // Less Than Or Equal - + RegisterValidator("lt", Lt) + RegisterValidator("lte", Lte) RegisterValidator("lowercase", Lowercase) // Unsupported: List RegisterValidator("mac_address", MacAddress) @@ -205,18 +201,18 @@ func init() { "extensions": BasicMessageResolver("The :attribute field must have one of the following extensions: :args."), // "file": BasicMessageResolver("The :attribute field must be a file."), "filled": BasicMessageResolver("The :attribute field must have a value."), - // "gt": MessageHintResolver{Hints: map[string]string{ - // "array": "The :attribute field must have more than :value items.", - // "file": "The :attribute field must be greater than :value kilobytes.", - // "numeric": "The :attribute field must be greater than :value.", - // "string": "The :attribute field must be greater than :value characters.", - // }}, - // "gte": MessageHintResolver{Hints: map[string]string{ - // "array": "The :attribute field must have :value items or more.", - // "file": "The :attribute field must be greater than or equal to :value kilobytes.", - // "numeric": "The :attribute field must be greater than or equal to :value.", - // "string": "The :attribute field must be greater than or equal to :value characters.", - // }}, + "gt": MessageHintResolver{Hints: map[string]string{ + "array": "The :attribute field must have more than :value items.", + "file": "The :attribute field must be greater than :value kilobytes.", + "numeric": "The :attribute field must be greater than :value.", + "string": "The :attribute field must be greater than :value characters.", + }}, + "gte": MessageHintResolver{Hints: map[string]string{ + "array": "The :attribute field must have :value items or more.", + "file": "The :attribute field must be greater than or equal to :value kilobytes.", + "numeric": "The :attribute field must be greater than or equal to :value.", + "string": "The :attribute field must be greater than or equal to :value characters.", + }}, "hex_color": BasicMessageResolver("The :attribute field must be a valid hexadecimal color."), // "image": BasicMessageResolver("The :attribute field must be an image."), "in": BasicMessageResolver("The selected :attribute is invalid."), @@ -228,18 +224,18 @@ func init() { "json": BasicMessageResolver("The :attribute field must be a valid JSON string."), // "list": BasicMessageResolver("The :attribute field must be a list."), "lowercase": BasicMessageResolver("The :attribute field must be lowercase."), - // "lt": MessageHintResolver{Hints: map[string]string{ - // "array": "The :attribute field must have less than :value items.", - // "file": "The :attribute field must be less than :value kilobytes.", - // "numeric": "The :attribute field must be less than :value.", - // "string": "The :attribute field must be less than :value characters.", - // }}, - // "lte": MessageHintResolver{Hints: map[string]string{ - // "array": "The :attribute field must not have more than :value items.", - // "file": "The :attribute field must be less than or equal to :value kilobytes.", - // "numeric": "The :attribute field must be less than or equal to :value.", - // "string": "The :attribute field must be less than or equal to :value characters.", - // }}, + "lt": MessageHintResolver{Hints: map[string]string{ + "array": "The :attribute field must have less than :value items.", + "file": "The :attribute field must be less than :value kilobytes.", + "numeric": "The :attribute field must be less than :value.", + "string": "The :attribute field must be less than :value characters.", + }}, + "lte": MessageHintResolver{Hints: map[string]string{ + "array": "The :attribute field must not have more than :value items.", + "file": "The :attribute field must be less than or equal to :value kilobytes.", + "numeric": "The :attribute field must be less than or equal to :value.", + "string": "The :attribute field must be less than or equal to :value characters.", + }}, "mac_address": BasicMessageResolver("The :attribute field must be a valid MAC address."), "max": MessageHintResolver{ Fallback: "The :attribute field must not be greater than :arg.", @@ -1715,3 +1711,157 @@ func Confirmed(ctx *ValidatorCtx) (string, bool) { return "", true } + +type SizeCompareStatus uint8 + +const ( + SizeCompareStatusEq SizeCompareStatus = iota + SizeCompareStatusLt + SizeCompareStatusGt +) + +func compareFieldsBase(ctx *ValidatorCtx) (SizeCompareStatus, ConvertStatus) { + if len(ctx.Args) == 0 { + return 0, Invalid + } + + ctx.UnwrapPointer() + + if !ctx.HasValue() { + return 0, ValueNil + } + + other := ctx.Field(ctx.Args[0]) + other.UnwrapPointer() + + if !other.HasValue() { + return 0, Invalid + } + + if ctx.IsNumeric() || other.IsNumeric() { + if !ctx.IsNumeric() || !other.IsNumeric() { + return 0, InvalidType + } + + if ctx.IsFloat() || other.IsFloat() { + aValue, aOk := ctx.Float64() + bValue, bOk := other.Float64() + if !aOk || !bOk { + return 0, InvalidType + } + + if aValue == bValue { + return SizeCompareStatusEq, ConverstionOk + } + if aValue < bValue { + return SizeCompareStatusLt, ConverstionOk + } + return SizeCompareStatusGt, ConverstionOk + } + + if ctx.IsUint() && other.IsUint() { + aValue := ctx.Value.Uint() + bValue := other.Value.Uint() + + if aValue == bValue { + return SizeCompareStatusEq, ConverstionOk + } + if aValue < bValue { + return SizeCompareStatusLt, ConverstionOk + } + return SizeCompareStatusGt, ConverstionOk + } + + aValue, aOk := ctx.Int64() + bValue, bOk := other.Int64() + if !aOk || !bOk { + return 0, InvalidType + } + + if aValue == bValue { + return SizeCompareStatusEq, ConverstionOk + } + if aValue < bValue { + return SizeCompareStatusLt, ConverstionOk + } + return SizeCompareStatusGt, ConverstionOk + } + + compareLen := false + if ctx.IsList() || other.IsList() { + if !ctx.IsList() || !other.IsList() { + return 0, InvalidType + } + compareLen = true + } + + if ctx.Kind() == reflect.String && other.Kind() == reflect.String { + compareLen = true + } + + if compareLen { + aLen := ctx.Value.Len() + bLen := other.Value.Len() + if aLen == bLen { + return SizeCompareStatusEq, ConverstionOk + } + if aLen < bLen { + return SizeCompareStatusLt, ConverstionOk + } + return SizeCompareStatusGt, ConverstionOk + } + + return 0, InvalidType +} + +func Gt(ctx *ValidatorCtx) (string, bool) { + sizeStatus, status := compareFieldsBase(ctx) + if !status.Oke() { + return status.Response() + } + + if sizeStatus != SizeCompareStatusGt { + return "lt", false + } + + return "", true +} + +func Gte(ctx *ValidatorCtx) (string, bool) { + sizeStatus, status := compareFieldsBase(ctx) + if !status.Oke() { + return status.Response() + } + + if sizeStatus == SizeCompareStatusLt { + return "lt", false + } + + return "", true +} + +func Lt(ctx *ValidatorCtx) (string, bool) { + sizeStatus, status := compareFieldsBase(ctx) + if !status.Oke() { + return status.Response() + } + + if sizeStatus != SizeCompareStatusLt { + return "gt", false + } + + return "", true +} + +func Lte(ctx *ValidatorCtx) (string, bool) { + sizeStatus, status := compareFieldsBase(ctx) + if !status.Oke() { + return status.Response() + } + + if sizeStatus == SizeCompareStatusGt { + return "gt", false + } + + return "", true +} diff --git a/translations/de.go b/translations/de.go index cfe9982..de93bff 100644 --- a/translations/de.go +++ b/translations/de.go @@ -54,18 +54,18 @@ func RegisterDeTranslations() { "extensions": BasicMessageResolver("Das :attribute Feld muss eine der folgenden Erweiterungen haben: :args."), // "file": BasicMessageResolver("Das :attribute Feld muss eine Datei sein."), "filled": BasicMessageResolver("Das :attribute Feld muss einen Wert haben."), - // "gt": MessageHintResolver{Hints: map[string]string{ - // "array": "Das :attribute Feld muss mehr als :value Elemente haben.", - // "file": "Das :attribute Feld muss größer als :value Kilobytes sein.", - // "numeric": "Das :attribute Feld muss größer als :value sein.", - // "string": "Das :attribute Feld muss größer als :value Zeichen lang sein.", - // }}, - // "gte": MessageHintResolver{Hints: map[string]string{ - // "array": "Das :attribute Feld muss :value Elemente oder mehr haben.", - // "file": "Das :attribute Feld muss größer oder gleich :value Kilobytes sein.", - // "numeric": "Das :attribute Feld muss größer oder gleich :value sein.", - // "string": "Das :attribute Feld muss größer oder gleich :value Zeichen lang sein.", - // }}, + "gt": MessageHintResolver{Hints: map[string]string{ + "array": "Das :attribute Feld muss mehr als :value Elemente haben.", + "file": "Das :attribute Feld muss größer als :value Kilobytes sein.", + "numeric": "Das :attribute Feld muss größer als :value sein.", + "string": "Das :attribute Feld muss größer als :value Zeichen lang sein.", + }}, + "gte": MessageHintResolver{Hints: map[string]string{ + "array": "Das :attribute Feld muss :value Elemente oder mehr haben.", + "file": "Das :attribute Feld muss größer oder gleich :value Kilobytes sein.", + "numeric": "Das :attribute Feld muss größer oder gleich :value sein.", + "string": "Das :attribute Feld muss größer oder gleich :value Zeichen lang sein.", + }}, "hex_color": BasicMessageResolver("Das :attribute Feld muss eine gültige hexadezimale Farbe sein."), // "image": BasicMessageResolver("Das :attribute Feld muss ein Bild sein."), "in": BasicMessageResolver("Der ausgewählte :attribute ist ungültig."), @@ -77,18 +77,18 @@ func RegisterDeTranslations() { "json": BasicMessageResolver("Das :attribute Feld muss eine gültige JSON-Zeichenkette sein."), // "list": BasicMessageResolver("Das :attribute Feld muss eine Liste sein."), "lowercase": BasicMessageResolver("Das :attribute Feld muss in Kleinbuchstaben sein."), - // "lt": MessageHintResolver{Hints: map[string]string{ - // "array": "Das :attribute Feld muss weniger als :value Elemente haben.", - // "file": "Das :attribute Feld muss kleiner als :value Kilobytes sein.", - // "numeric": "Das :attribute Feld muss kleiner als :value sein.", - // "string": "Das :attribute Feld muss kleiner als :value Zeichen lang sein.", - // }}, - // "lte": MessageHintResolver{Hints: map[string]string{ - // "array": "Das :attribute Feld darf nicht mehr als :value Elemente haben.", - // "file": "Das :attribute Feld darf nicht größer als :value Kilobytes sein.", - // "numeric": "Das :attribute Feld darf nicht größer als :value sein.", - // "string": "Das :attribute Feld darf nicht größer als :value Zeichen lang sein.", - // }}, + "lt": MessageHintResolver{Hints: map[string]string{ + "array": "Das :attribute Feld muss weniger als :value Elemente haben.", + "file": "Das :attribute Feld muss kleiner als :value Kilobytes sein.", + "numeric": "Das :attribute Feld muss kleiner als :value sein.", + "string": "Das :attribute Feld muss kleiner als :value Zeichen lang sein.", + }}, + "lte": MessageHintResolver{Hints: map[string]string{ + "array": "Das :attribute Feld darf nicht mehr als :value Elemente haben.", + "file": "Das :attribute Feld darf nicht größer als :value Kilobytes sein.", + "numeric": "Das :attribute Feld darf nicht größer als :value sein.", + "string": "Das :attribute Feld darf nicht größer als :value Zeichen lang sein.", + }}, "mac_address": BasicMessageResolver("Das :attribute Feld muss eine gültige MAC-Adresse sein."), "max": MessageHintResolver{ Fallback: "Das :attribute Feld darf nicht größer als :arg sein.", diff --git a/translations/es.go b/translations/es.go index 2703ee0..12c9026 100644 --- a/translations/es.go +++ b/translations/es.go @@ -54,18 +54,18 @@ func RegisterEsTranslations() { "extensions": BasicMessageResolver("El campo :attribute debe tener una de las siguientes extensiones: :args."), // "file": BasicMessageResolver("El campo :attribute debe ser un archivo."), "filled": BasicMessageResolver("El campo :attribute debe tener un valor."), - // "gt": MessageHintResolver{Hints: map[string]string{ - // "array": "El campo :attribute debe tener más de :value elementos.", - // "file": "El campo :attribute debe ser mayor que :value kilobytes.", - // "numeric": "El campo :attribute debe ser mayor que :value.", - // "string": "El campo :attribute debe ser mayor que :value caracteres.", - // }}, - // "gte": MessageHintResolver{Hints: map[string]string{ - // "array": "El campo :attribute debe tener :value elementos o más.", - // "file": "El campo :attribute debe ser mayor o igual que :value kilobytes.", - // "numeric": "El campo :attribute debe ser mayor o igual que :value.", - // "string": "El campo :attribute debe ser mayor o igual que :value caracteres.", - // }}, + "gt": MessageHintResolver{Hints: map[string]string{ + "array": "El campo :attribute debe tener más de :value elementos.", + "file": "El campo :attribute debe ser mayor que :value kilobytes.", + "numeric": "El campo :attribute debe ser mayor que :value.", + "string": "El campo :attribute debe ser mayor que :value caracteres.", + }}, + "gte": MessageHintResolver{Hints: map[string]string{ + "array": "El campo :attribute debe tener :value elementos o más.", + "file": "El campo :attribute debe ser mayor o igual que :value kilobytes.", + "numeric": "El campo :attribute debe ser mayor o igual que :value.", + "string": "El campo :attribute debe ser mayor o igual que :value caracteres.", + }}, "hex_color": BasicMessageResolver("El campo :attribute debe ser un color hexadecimal válido."), // "image": BasicMessageResolver("El campo :attribute debe ser una imagen."), "in": BasicMessageResolver("El :attribute seleccionado es inválido."), @@ -77,18 +77,18 @@ func RegisterEsTranslations() { "json": BasicMessageResolver("El campo :attribute debe ser una cadena JSON válida."), // "list": BasicMessageResolver("El campo :attribute debe ser una lista."), "lowercase": BasicMessageResolver("El campo :attribute debe ser en minúsculas."), - // "lt": MessageHintResolver{Hints: map[string]string{ - // "array": "El campo :attribute debe tener menos de :value elementos.", - // "file": "El campo :attribute debe ser menor que :value kilobytes.", - // "numeric": "El campo :attribute debe ser menor que :value.", - // "string": "El campo :attribute debe ser menor que :value caracteres.", - // }}, - // "lte": MessageHintResolver{Hints: map[string]string{ - // "array": "El campo :attribute no debe tener más de :value elementos.", - // "file": "El campo :attribute debe ser menor o igual que :value kilobytes.", - // "numeric": "El campo :attribute debe ser menor o igual que :value.", - // "string": "El campo :attribute debe ser menor o igual que :value caracteres.", - // }}, + "lt": MessageHintResolver{Hints: map[string]string{ + "array": "El campo :attribute debe tener menos de :value elementos.", + "file": "El campo :attribute debe ser menor que :value kilobytes.", + "numeric": "El campo :attribute debe ser menor que :value.", + "string": "El campo :attribute debe ser menor que :value caracteres.", + }}, + "lte": MessageHintResolver{Hints: map[string]string{ + "array": "El campo :attribute no debe tener más de :value elementos.", + "file": "El campo :attribute debe ser menor o igual que :value kilobytes.", + "numeric": "El campo :attribute debe ser menor o igual que :value.", + "string": "El campo :attribute debe ser menor o igual que :value caracteres.", + }}, "mac_address": BasicMessageResolver("El campo :attribute debe ser una dirección MAC válida."), "max": MessageHintResolver{ Fallback: "El campo :attribute no debe ser mayor que :arg.", diff --git a/translations/fr.go b/translations/fr.go index f2e765b..48647aa 100644 --- a/translations/fr.go +++ b/translations/fr.go @@ -54,18 +54,18 @@ func RegisterFrTranslations() { "extensions": BasicMessageResolver("Le champ :attribute doit avoir l'une des extensions suivantes : :args."), // "file": BasicMessageResolver("Le champ :attribute doit être un fichier."), "filled": BasicMessageResolver("Le champ :attribute doit avoir une valeur."), - // "gt": MessageHintResolver{Hints: map[string]string{ - // "array": "Le champ :attribute doit avoir plus de :value éléments.", - // "file": "Le champ :attribute doit être supérieur à :value kilo-octets.", - // "numeric": "Le champ :attribute doit être supérieur à :value.", - // "string": "Le champ :attribute doit être supérieur à :value caractères.", - // }}, - // "gte": MessageHintResolver{Hints: map[string]string{ - // "array": "Le champ :attribute doit avoir au moins :value éléments.", - // "file": "Le champ :attribute doit être supérieur ou égal à :value kilo-octets.", - // "numeric": "Le champ :attribute doit être supérieur ou égal à :value.", - // "string": "Le champ :attribute doit être supérieur ou égal à :value caractères.", - // }}, + "gt": MessageHintResolver{Hints: map[string]string{ + "array": "Le champ :attribute doit avoir plus de :value éléments.", + "file": "Le champ :attribute doit être supérieur à :value kilo-octets.", + "numeric": "Le champ :attribute doit être supérieur à :value.", + "string": "Le champ :attribute doit être supérieur à :value caractères.", + }}, + "gte": MessageHintResolver{Hints: map[string]string{ + "array": "Le champ :attribute doit avoir au moins :value éléments.", + "file": "Le champ :attribute doit être supérieur ou égal à :value kilo-octets.", + "numeric": "Le champ :attribute doit être supérieur ou égal à :value.", + "string": "Le champ :attribute doit être supérieur ou égal à :value caractères.", + }}, "hex_color": BasicMessageResolver("Le champ :attribute doit être une couleur hexadécimale valide."), // "image": BasicMessageResolver("Le champ :attribute doit être une image."), "in": BasicMessageResolver("Le :attribute sélectionné est non valide."), @@ -77,18 +77,18 @@ func RegisterFrTranslations() { "json": BasicMessageResolver("Le champ :attribute doit être une chaîne JSON valide."), // "list": BasicMessageResolver("Le champ :attribute doit être une liste."), "lowercase": BasicMessageResolver("Le champ :attribute doit être en minuscules."), - // "lt": MessageHintResolver{Hints: map[string]string{ - // "array": "Le champ :attribute doit avoir moins de :value éléments.", - // "file": "Le champ :attribute doit être inférieur à :value kilo-octets.", - // "numeric": "Le champ :attribute doit être inférieur à :value.", - // "string": "Le champ :attribute doit être inférieur à :value caractères.", - // }}, - // "lte": MessageHintResolver{Hints: map[string]string{ - // "array": "Le champ :attribute ne doit pas avoir plus de :value éléments.", - // "file": "Le champ :attribute doit être inférieur ou égal à :value kilo-octets.", - // "numeric": "Le champ :attribute doit être inférieur ou égal à :value.", - // "string": "Le champ :attribute doit être inférieur ou égal à :value caractères.", - // }}, + "lt": MessageHintResolver{Hints: map[string]string{ + "array": "Le champ :attribute doit avoir moins de :value éléments.", + "file": "Le champ :attribute doit être inférieur à :value kilo-octets.", + "numeric": "Le champ :attribute doit être inférieur à :value.", + "string": "Le champ :attribute doit être inférieur à :value caractères.", + }}, + "lte": MessageHintResolver{Hints: map[string]string{ + "array": "Le champ :attribute ne doit pas avoir plus de :value éléments.", + "file": "Le champ :attribute doit être inférieur ou égal à :value kilo-octets.", + "numeric": "Le champ :attribute doit être inférieur ou égal à :value.", + "string": "Le champ :attribute doit être inférieur ou égal à :value caractères.", + }}, "mac_address": BasicMessageResolver("Le champ :attribute doit être une adresse MAC valide."), "max": MessageHintResolver{ Fallback: "Le champ :attribute ne doit pas être supérieur à :arg.", diff --git a/translations/nl.go b/translations/nl.go index 38c5dfc..e86891b 100644 --- a/translations/nl.go +++ b/translations/nl.go @@ -54,18 +54,18 @@ func RegisterNlTranslations() { "extensions": BasicMessageResolver("Het :attribute veld moet een van de volgende extensies hebben: :args."), // "file": BasicMessageResolver("Het :attribute veld moet een bestand zijn."), "filled": BasicMessageResolver("Het :attribute veld moet een waarde hebben."), - // "gt": MessageHintResolver{Hints: map[string]string{ - // "array": "Het :attribute veld moet meer dan :value items bevatten.", - // "file": "Het :attribute veld moet groter zijn dan :value kilobytes.", - // "numeric": "Het :attribute veld moet groter zijn dan :value.", - // "string": "Het :attribute veld moet groter zijn dan :value tekens.", - // }}, - // "gte": MessageHintResolver{Hints: map[string]string{ - // "array": "Het :attribute veld moet :value items of meer bevatten.", - // "file": "Het :attribute veld moet groter zijn dan of gelijk aan :value kilobytes.", - // "numeric": "Het :attribute veld moet groter zijn dan of gelijk aan :value.", - // "string": "Het :attribute veld moet groter zijn dan of gelijk aan :value tekens.", - // }}, + "gt": MessageHintResolver{Hints: map[string]string{ + "array": "Het :attribute veld moet meer dan :value items bevatten.", + "file": "Het :attribute veld moet groter zijn dan :value kilobytes.", + "numeric": "Het :attribute veld moet groter zijn dan :value.", + "string": "Het :attribute veld moet groter zijn dan :value tekens.", + }}, + "gte": MessageHintResolver{Hints: map[string]string{ + "array": "Het :attribute veld moet :value items of meer bevatten.", + "file": "Het :attribute veld moet groter zijn dan of gelijk aan :value kilobytes.", + "numeric": "Het :attribute veld moet groter zijn dan of gelijk aan :value.", + "string": "Het :attribute veld moet groter zijn dan of gelijk aan :value tekens.", + }}, "hex_color": BasicMessageResolver("Het :attribute veld moet een geldige hexadecimale kleur zijn."), // "image": BasicMessageResolver("Het :attribute veld moet een afbeelding zijn."), "in": BasicMessageResolver("De geselecteerde :attribute is ongeldig."), @@ -77,18 +77,18 @@ func RegisterNlTranslations() { "json": BasicMessageResolver("Het :attribute veld moet een geldige JSON-tekst zijn."), // "list": BasicMessageResolver("Het :attribute veld moet een lijst zijn."), "lowercase": BasicMessageResolver("Het :attribute veld moet in kleine letters zijn."), - // "lt": MessageHintResolver{Hints: map[string]string{ - // "array": "Het :attribute veld moet minder dan :value items bevatten.", - // "file": "Het :attribute veld moet kleiner zijn dan :value kilobytes.", - // "numeric": "Het :attribute veld moet kleiner zijn dan :value.", - // "string": "Het :attribute veld moet kleiner zijn dan :value tekens.", - // }}, - // "lte": MessageHintResolver{Hints: map[string]string{ - // "array": "Het :attribute veld mag niet meer dan :value items bevatten.", - // "file": "Het :attribute veld mag niet groter zijn dan of gelijk aan :value kilobytes.", - // "numeric": "Het :attribute veld mag niet groter zijn dan of gelijk aan :value.", - // "string": "Het :attribute veld mag niet groter zijn dan of gelijk aan :value tekens.", - // }}, + "lt": MessageHintResolver{Hints: map[string]string{ + "array": "Het :attribute veld moet minder dan :value items bevatten.", + "file": "Het :attribute veld moet kleiner zijn dan :value kilobytes.", + "numeric": "Het :attribute veld moet kleiner zijn dan :value.", + "string": "Het :attribute veld moet kleiner zijn dan :value tekens.", + }}, + "lte": MessageHintResolver{Hints: map[string]string{ + "array": "Het :attribute veld mag niet meer dan :value items bevatten.", + "file": "Het :attribute veld mag niet groter zijn dan of gelijk aan :value kilobytes.", + "numeric": "Het :attribute veld mag niet groter zijn dan of gelijk aan :value.", + "string": "Het :attribute veld mag niet groter zijn dan of gelijk aan :value tekens.", + }}, "mac_address": BasicMessageResolver("Het :attribute veld moet een geldig MAC-adres zijn."), "max": MessageHintResolver{ Fallback: "Het :attribute veld mag niet groter zijn dan :arg.",