From b4c97b0e88a1ea7113f62191f240fbdd7f753d94 Mon Sep 17 00:00:00 2001 From: ApamateSoft Date: Sun, 16 Apr 2023 19:16:37 -0400 Subject: [PATCH 1/2] fix documentation and fix default messages --- README.md | 249 +++++++++--------- pom.xml | 2 +- .../ApamateSoft/validator/Validator.java | 2 +- .../validator/messages/MessagesEn.java | 4 +- translations/README-es.md | 64 +++-- 5 files changed, 159 insertions(+), 162 deletions(-) diff --git a/README.md b/README.md index 3d8a9ee..884a68c 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,31 @@ # Validator -Facilitates the validation of Strings by chaining a series of rules. +Facilitates the validation of Strings by chaining series of rules. ## Translations - [Spanish](translations/README-es.md) -## Release Notes 1.3.0 -- Added annotations. -- Renamed the `dateFormat` rule to `date`. -- Renamed the `mustContainMinimum` rule to `mustContainMin`. -- Renamed the `isValidOrFail` function to `validOrFail`. +## Release Notes 1.3.1 +- Fixed translation problem of the default message of the name rule in English. +- Changed the error message for the `onlyNumbers` rule. + +## Installation ### Download the JAR -[Validator-1.3.0.jar](https://repo1.maven.org/maven2/io/github/ApamateSoft/Validator/1.3.0/Validator-1.3.0.jar) +[Validator-1.3.1.jar](https://repo1.maven.org/maven2/io/github/ApamateSoft/Validator/1.3.1/Validator-1.3.1.jar) ### Maven ```xml io.github.ApamateSoft Validator - 1.3.0 + 1.3.1 ``` ### Gradle ```groovy -implementation group: 'io.github.ApamateSoft', name: 'Validator', version: '1.3.0' +implementation group: 'io.github.ApamateSoft', name: 'Validator', version: '1.3.1' ``` ## Starting @@ -88,41 +88,41 @@ public class HelloValidator { Validator offers a series of predefined rules, trying to cover the most common validation cases. -| Rule | Description | -|---------------------|---------------------------------------------------------------------------------------------------------------| -| `date` | Validates that the String to evaluate matches the specified date format | -| `email` | Validates that the String has an email format | -| `expirationDate` | Validates that the entered date has not expired | -| `httpLink` | Validates that the String is a link with http format | -| `httpsLink` | Validates that the String is a link with https format | -| `ip` | Validates that the String is an ip format | -| `ipv4` | Validates that the String is an ipv4 format | -| `ipv6` | Validates that the String is an ipv6 format | -| `length` | Validates that the String has an exact length of characters | -| `link` | Validates that the String is a link format | -| `maxLength` | Validates that the length of the String is not greater than the condition | -| `maxValue` | Validates that the value of the String is not greater than the condition | +| Rule | Description | +|---------------------|--------------------------------------------------------------------------------------------------------------| +| `date` | Validates that the String to evaluate matches the specified date format | +| `email` | Validates that the String has an email format | +| `expirationDate` | Validates that the entered date has not expired | +| `httpLink` | Validates that the String is a link with http format | +| `httpsLink` | Validates that the String is a link with https format | +| `ip` | Validates that the String is an ip format | +| `ipv4` | Validates that the String is an ipv4 format | +| `ipv6` | Validates that the String is an ipv6 format | +| `length` | Validates that the String has an exact length of characters | +| `link` | Validates that the String is a link format | +| `maxLength` | Validates that the length of the String is not greater than the condition | +| `maxValue` | Validates that the value of the String is not greater than the condition | | `minAge` | Validates that the period from the entered date to the current date is greater than or equal to a minimum age | -| `minLength` | Validates that the length of the String is not less than the condition | -| `minValue` | Validates that the value of the String is not less than the condition | -| `mustContainMin` | Validates that the String contains at least a minimum number of characters included in the condition | -| `mustContainOne` | Validates that the String contains at least one character included in the condition | -| `name` | Validates that the String is a proper name | -| `notContain` | Validates that the String does not contain any characters included in the condition | -| `number` | Validates that the String is a numeric format | -| `numberPattern` | Validates that the String matches the pattern, replacing the x's with numbers | -| `onlyAlphanumeric` | Validates that the String contains only alphanumeric characters | -| `onlyLetters` | Validates that the String contains only letters | -| `onlyNumbers` | Validates that the String to evaluate only contains numeric characters | -| `rangeLength` | Validates that the length of the String is in the established range | -| `rangeValue` | Validates that the value of the String is in the established range | -| `regExp` | Validates that the String matches the regular expression | -| `required` | Validates that the String is different from null and empty | -| `shouldOnlyContain` | Validates that the String only contains characters included in the condition | -| `time` | Validates that the String is a time format | -| `time12` | Validates that the String is a time with 12-hour format | -| `time24` | Validates that the String is a time with 24-hour format | -| `wwwLink` | Validates that the String is a link with www format | +| `minLength` | Validates that the length of the String is not less than the condition | +| `minValue` | Validates that the value of the String is not less than the condition | +| `mustContainMin` | Validates that the String contains at least a minimum number of characters included in the condition | +| `mustContainOne` | Validates that the String contains at least one character included in the condition | +| `name` | Validates that the String is a proper name | +| `notContain` | Validates that the String does not contain any character included in the condition | +| `number` | Validates that the String is a numeric format | +| `numberPattern` | Validates that the String matches the pattern, replacing the x's with numbers | +| `onlyAlphanumeric` | Validates that the String contains only alphanumeric characters | +| `onlyLetters` | Validates that the String contains only letters | +| `onlyNumbers` | Validates that the String to evaluate only contains numeric characters | +| `rangeLength` | Validates that the length of the String is in the established range | +| `rangeValue` | Validates that the value of the String is in the established range | +| `regExp` | Validates that the String matches the regular expression | +| `required` | Validates that the String is different from null and empty | +| `shouldOnlyContain` | Validates that the String only contains characters included in the condition | +| `time` | Validates that the String is a time format | +| `time12` | Validates that the String is a time with 12-hour format | +| `time24` | Validates that the String is a time with 24-hour format | +| `wwwLink` | Validates that the String is a link with www format | Predefined rules can simplify the definition of a Validator. @@ -144,42 +144,42 @@ public class HelloValidator { Validator also offers the predefined rule set in the form of annotations. -| Annotations | Description | -|----------------------|---------------------------------------------------------------------------------------------------------------| -| `@Compare` | Validates that the String to be evaluated matches the value of the attribute passed as parameter | -| `@Date` | Validates that the String to be evaluated matches the specified date format | -| `@Email` | Validates that the String has an email format | -| `@ExpirationDate` | Validates that the entered date has not expired | -| `@HttpLink` | Validates that the String is a link in http format | -| `@HttpsLink` | Validates that the String is a link with format https | -| `@ip` | Validates that the String is a format of ip | -| `@Ipv4` | Validates that the String is an ipv4 format | -| `@Ipv6` | Validates that the String is an ipv6 format | -| `@Length` | Validates that the String has an exact length of characters | -| `@Link` | Validates that the String is a binding format | -| `@MaxLength` | Validates that the length of the String is not greater than the condition | -| `@MaxValue` | Validates that the value of the String is not greater than the condition | +| Annotations | Description | +|----------------------|------------------------------------------------------------------------------------------------------------| +| `@Compare` | Validates that the String to be evaluated matches the value of the attribute passed as parameter | +| `@Date` | Validates that the String to be evaluated matches the specified date format | +| `@Email` | Validates that the String has an email format | +| `@ExpirationDate` | Validates that the entered date has not expired | +| `@HttpLink` | Validates that the String is a link in http format | +| `@HttpsLink` | Validates that the String is a link with format https | +| `@ip` | Validates that the String is a format of ip | +| `@Ipv4` | Validates that the String is an ipv4 format | +| `@Ipv6` | Validates that the String is an ipv6 format | +| `@Length` | Validates that the String has an exact length of characters | +| `@Link` | Validates that the String is a link format | +| `@MaxLength` | Validates that the length of the String is not greater than the condition | +| `@MaxValue` | Validates that the value of the String is not greater than the condition | | `@MinAge` | Validates that the period from the entered date to the current date is greater than or equal to a minimum age | -| `@MinLength` | Validates that the length of the String is not less than the condition | -| `@MinValue` | Validates that the value of the String is not less than the condition | -| `@MustContainMin` | Validates that the String contains at least a minimum number of characters included in the condition | -| `@MustContainOne` | Validates that the String contains at least one character included in the condition | -| `@Mummy` | Validates that the String is a proper name | -| `@MotContain` | Validates that the String does not contain any characters included in the condition | -| `@Number` | Validates that the String is a numeric format | -| `@MumberPattern` | Validates that the String matches the pattern, replacing the x's with numbers | -| `@OnlyAlphanumeric` | Validates that the String contains only alphanumeric characters | -| `@OnlyLetters` | Validates that the String contains only letters | -| `@OnlyNumbers` | Validates that the String to evaluate only contains numeric characters | -| `@RangeLength` | Validates that the length of the String is in the established range | -| `@RangeValue` | Validates that the value of the String is in the established range | -| `@RegExp` | Validates that the String matches the regular expression | -| `@Required` | Validates that the String is different from null and empty. | -| `@ShouldOnlyContain` | Validates that the String only contains characters included in the condition | -| `@Time` | Validates that the String is a time format | -| `@Time12` | Validates that the String is a time with 12-hour format | -| `@Time24` | Validates that the String is a time with 24-hour format | -| `@WwwLink` | Validates that the String is a link with format www | +| `@MinLength` | Validates that the length of the String is not less than the condition | +| `@MinValue` | Validates that the value of the String is not less than the condition | +| `@MustContainMin` | Validates that the String contains at least a minimum number of characters included in the condition | +| `@MustContainOne` | Validates that the String contains at least one character included in the condition | +| `@Mummy` | Validates that the String is a proper name | +| `@MotContain` | Validates that the String does not contain any character included in the condition | +| `@Number` | Validates that the String is a numeric format | +| `@MumberPattern` | Validates that the String matches the pattern, replacing the x's with numbers | +| `@OnlyAlphanumeric` | Validates that the String contains only alphanumeric characters | +| `@OnlyLetters` | Validates that the String contains only letters | +| `@OnlyNumbers` | Validates that the String to evaluate only contains numeric characters | +| `@RangeLength` | Validates that the length of the String is in the established range | +| `@RangeValue` | Validates that the value of the String is in the established range | +| `@RegExp` | Validates that the String matches the regular expression | +| `@Required` | Validates that the String is different from null and empty. | +| `@ShouldOnlyContain` | Validates that the String only contains characters included in the condition | +| `@Time` | Validates that the String is a time format | +| `@Time12` | Validates that the String is a time with 12-hour format | +| `@Time24` | Validates that the String is a time with 24-hour format | +| `@WwwLink` | Validates that the String is a link with format www | Below is an example of how to implement annotations. @@ -252,7 +252,7 @@ for Spanish messages, both classes implement the `Messages` interface. |---------------------|----------------------------------------------------------|-----------------------------------------------------------| | `compare` | Not match | No coinciden | | `date` | The date does not match the format %s | La fecha no coincide con el formato %s | -| `email` | Email invalid | Correo electrónico invalido | +| `email` | Email invalid | Correo electrónico inválido | | `expirationDate` | Expired date | Fecha expirada | | `httpLink` | Invalid http link | Enlace http inválido | | `httpsLink` | Invalid https link | Enlace https inválido | @@ -263,18 +263,18 @@ for Spanish messages, both classes implement the `Messages` interface. | `link` | Invalid link | Enlace inválido | | `maxLength` | %d or less characters required | Se requiere %d o menos caracteres | | `maxValue` | The value cannot be greater than %1$.2f | El valor no puede ser mayor a %1$.2f | -| `minAge` | You must be at least %d years old | Se debe tener al menos %d años | +| `minAge` | Must be at least %d years old | Se debe tener al menos %d años | | `minLength` | %d or more characters are required | Se requiere %d o más caracteres | | `minValue` | The value cannot be less than %1$.2f | El valor no puede ser menor a %1$.2f | | `mustContainMin` | At least %d of the following characters are required: %s | Se requiere al menos %d de los siguientes caracteres: %s | | `mustContainOne` | At least one of the following characters is required: %s | Se requiere al menos uno de los siguientes caracteres: %s | -| `name` | Debe introducir un nombre personal válido | Debe introducir un nombre personal válido | +| `name` | Must enter a valid personal name | Debe introducir un nombre personal válido | | `notContain` | The following characters aren't admitted %s | No se admiten los siguientes caracteres %s | | `number` | It is not a number | No es un número | | `numberPattern` | Does not match pattern %s | No coincide con el patrón %s | | `onlyAlphanumeric` | Just alphanumeric characters | Solo caracteres alfanuméricos | | `onlyLetters` | Only letters | Solo letras | -| `onlyNumbers` | Just numbers | Solo números | +| `onlyNumbers` | Only numbers | Solo números | | `rangeLength` | The text must contain between %d to %d characters | El texto debe contener entre %d a %d caracteres | | `rangeValue` | The value must be between %1$.2f and %1$.2f | El valor debe estar entre %1$.2f y %1$.2f | | `regExp` | The value does not match the regular expression %s | El valor no coincide con la expresión regular %s | @@ -359,8 +359,8 @@ public class HelloValidator { .build(); public HelloValidator() { - // Solo se ejecuta si falla la validación de alguna regla - validator.onInvalidEvaluation(message -> System.out.println(message)); // "El texto es diferente de 'xxx'" + // It is only executed if the validation of some rule fails + validator.onInvalidEvaluation(message -> System.out.println(message)); // "The text is different from 'xxx'" } public void submit() { @@ -436,8 +436,7 @@ class HelloValidator { ### Alphabets -Some rules require as a parameter a set of characters that may or may not be required for validation. TO -that set is named as alphabet and validator returns a set of the alphabets as constants in the class +Some rules require as a parameter a set of characters that may or may not be required for validation. That set is named as alphabet and validator returns a set of the alphabets as constants in the class called `Alphabet`. | Name | Alphabet | @@ -460,7 +459,7 @@ called `Alphabet`. Some rules, as in the case of `regExp`, can be passed a regular expression as a parameter. Validator too offers a class with a set of regular expressions as constants in the `RegularExpressions` class. -| regular expression | match for | +| Regular expression | Match for | |--------------------|------------------------------------------------------------------------------------------------------------------| | EMAIL | example@mail.com | | NUMBER | 123456789 | @@ -483,47 +482,47 @@ offers a class with a set of regular expressions as constants in the `RegularExp All the rules use simple validators to validate if the String to be evaluated is valid or not. These validators are static methods belonging to the `Validators` class that only return a boolean value. -| Validator | Description | -|---------------------|---------------------------------------------------------------------------------------------------------------| -| `date` | Validates that the String to evaluate matches the specified date format | -| `email` | Validates that the String has an email format | -| `expirationDate` | Validates that the entered date has not expired | -| `httpLink` | Validates that the String is a link with http format | -| `httpsLink` | Validates that the String is a link with https format | -| `ip` | Validates that the String is an ip format | -| `ipv4` | Validates that the String is an ipv4 format | -| `ipv6` | Validates that the String is an ipv6 format | -| `length` | Validates that the String has an exact length of characters | -| `link` | Validates that the String is a link format | -| `maxLength` | Validates that the length of the String is not greater than the condition | -| `maxValue` | Validates that the value of the String is not greater than the condition | +| Validator | Description | +|---------------------|--------------------------------------------------------------------------------------------------------------| +| `date` | Validates that the String to evaluate matches the specified date format | +| `email` | Validates that the String has an email format | +| `expirationDate` | Validates that the entered date has not expired | +| `httpLink` | Validates that the String is a link with http format | +| `httpsLink` | Validates that the String is a link with https format | +| `ip` | Validates that the String is an ip format | +| `ipv4` | Validates that the String is an ipv4 format | +| `ipv6` | Validates that the String is an ipv6 format | +| `length` | Validates that the String has an exact length of characters | +| `link` | Validates that the String is a link format | +| `maxLength` | Validates that the length of the String is not greater than the condition | +| `maxValue` | Validates that the value of the String is not greater than the condition | | `minAge` | Validates that the period from the entered date to the current date is greater than or equal to a minimum age | -| `minLength` | Validates that the length of the String is not less than the condition | -| `minValue` | Validates that the value of the String is not less than the condition | -| `mustContainMin` | Validates that the String contains at least a minimum number of characters included in the condition | -| `mustContainOne` | Validates that the String contains at least one character included in the condition | -| `name` | Validates that the String is a proper name | -| `notContain` | Validates that the String does not contain any characters included in the condition | -| `number` | Validates that the String is a numeric format | -| `numberPattern` | Validates that the String matches the pattern, replacing the x's with numbers | -| `onlyAlphanumeric` | Validates that the String contains only alphanumeric characters | -| `onlyLetters` | Validates that the String contains only letters | -| `onlyNumbers` | Validates that the String to evaluate only contains numeric characters | -| `rangeLength` | Validates that the length of the String is in the established range | -| `rangeValue` | Validates that the value of the String is in the established range | -| `regExp` | Validates that the String matches the regular expression | -| `required` | Validates that the String is different from null and empty | -| `shouldOnlyContain` | Validates that the String only contains characters included in the condition | -| `time` | Validates that the String is a time format | -| `time12` | Validates that the String is a time with 12-hour format | -| `time24` | Validates that the String is a time with 24-hour format | -| `wwwLink` | Validates that the String is a link with www format | +| `minLength` | Validates that the length of the String is not less than the condition | +| `minValue` | Validates that the value of the String is not less than the condition | +| `mustContainMin` | Validates that the String contains at least a minimum number of characters included in the condition | +| `mustContainOne` | Validates that the String contains at least one character included in the condition | +| `name` | Validates that the String is a proper name | +| `notContain` | Validates that the String does not contain any character included in the condition | +| `number` | Validates that the String is a numeric format | +| `numberPattern` | Validates that the String matches the pattern, replacing the x's with numbers | +| `onlyAlphanumeric` | Validates that the String contains only alphanumeric characters | +| `onlyLetters` | Validates that the String contains only letters | +| `onlyNumbers` | Validates that the String to evaluate only contains numeric characters | +| `rangeLength` | Validates that the length of the String is in the established range | +| `rangeValue` | Validates that the value of the String is in the established range | +| `regExp` | Validates that the String matches the regular expression | +| `required` | Validates that the String is different from null and empty | +| `shouldOnlyContain` | Validates that the String only contains characters included in the condition | +| `time` | Validates that the String is a time format | +| `time12` | Validates that the String is a time with 12-hour format | +| `time24` | Validates that the String is a time with 24-hour format | +| `wwwLink` | Validates that the String is a link with www format | ## Recommendations -Commonly, there are several instances of Strings to which to apply the same validation rules. for these cases -It is recommended to define Validators per context, in order to define our Validator once and reuse it. This -Logic is possible, since Validator includes a `.copy` method which generates copies of it. +Commonly, there are several instances of Strings to which to apply the same validation rules. For these cases, +it is recommended to define Validators per context, in order to define our Validator once and reuse it. This +logic is possible, since Validator includes a `.copy` method which generates copies of it. ```java import io.github.ApamateSoft.validator.exceptions.InvalidEvaluationException; @@ -562,7 +561,7 @@ public class Register { private String email, phone, psw, pswConfirmation; - public Login() { + public Register() { emailValidator.onInvalidEvaluation(System.out::println); pswValidator.onInvalidEvaluation(System.out::println); phoneValidator.onInvalidEvaluation(System.out::println); diff --git a/pom.xml b/pom.xml index c27c88c..7086667 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ io.github.ApamateSoft Validator - 1.3.0 + 1.3.1 jar Validator diff --git a/src/main/java/io/github/ApamateSoft/validator/Validator.java b/src/main/java/io/github/ApamateSoft/validator/Validator.java index d3c23dd..a8f92de 100644 --- a/src/main/java/io/github/ApamateSoft/validator/Validator.java +++ b/src/main/java/io/github/ApamateSoft/validator/Validator.java @@ -23,7 +23,7 @@ * Facilitates the validation of Strings by chaining a series of rules * * @author ApamateSoft - * @version 1.3.0 + * @version 1.3.1 */ public class Validator implements Cloneable { diff --git a/src/main/java/io/github/ApamateSoft/validator/messages/MessagesEn.java b/src/main/java/io/github/ApamateSoft/validator/messages/MessagesEn.java index 05e86e4..ee123d2 100644 --- a/src/main/java/io/github/ApamateSoft/validator/messages/MessagesEn.java +++ b/src/main/java/io/github/ApamateSoft/validator/messages/MessagesEn.java @@ -89,7 +89,7 @@ public String getMustContainOneMessage() { @Override public String getNameMessage() { - return "Debe introducir un nombre personal válido"; + return "Must enter a valid personal name"; } @Override @@ -124,7 +124,7 @@ public String getOnlyLettersMessage() { @Override public String getOnlyNumbersMessage() { - return "Just numbers"; + return "Only numbers"; } @Override diff --git a/translations/README-es.md b/translations/README-es.md index c2ea80a..b12a181 100644 --- a/translations/README-es.md +++ b/translations/README-es.md @@ -4,29 +4,27 @@ Versión en [Inglés](../README.md) Facilita la validación de Strings encadenando una serie de reglas. -## Notas de version 1.3.0 -- Se ha añadido las anotaciones. -- Se ha renombrado el la regla `dateFormat` a `date`. -- Se ha renombrado la regla `mustContainMinimum` a `mustContainMin`. -- Se ha renombrado la función `isValidOrFail` a `validOrFail`. +## Notas de version 1.3.1 +- Solucionado problema de traducción del mensaje por defecto de la regla name en inglés. +- Se ha cambiado el mensaje de error de la regla `onlyNumbers`. ## Instalación ### Descargar el JAR -[Validator-1.3.0.jar](https://repo1.maven.org/maven2/io/github/ApamateSoft/Validator/1.3.0/Validator-1.3.0.jar) +[Validator-1.3.1.jar](https://repo1.maven.org/maven2/io/github/ApamateSoft/Validator/1.3.1/Validator-1.3.1.jar) ### Maven ```xml io.github.ApamateSoft Validator - 1.3.0 + 1.3.1 ``` ### Gradle ```groovy -implementation group: 'io.github.ApamateSoft', name: 'Validator', version: '1.3.0' +implementation group: 'io.github.ApamateSoft', name: 'Validator', version: '1.3.1' ``` ## Empezando @@ -49,7 +47,7 @@ public class HelloValidator { return evaluate != null; }); - // Segunda regla, solo se aprobará si el String a evaluar es igual a "xxx", en caso contrario mostrara el mensaje + // Segunda regla, solo se aprobará si el String a evaluar es igual a "xxx", en caso contrario mostrará el mensaje // "El texto es diferente de 'xxx'" validator.rule("El texto es diferente de 'xxx'", (String evaluate) -> { return evaluate.equals("xxx"); @@ -59,7 +57,7 @@ public class HelloValidator { } ``` -La función `rule` de validator permite crear reglas de validación específicas, asociadas a un mensaje de error en caso +La función `rule` de validator permite crear reglas de validación específicas, asociadas a un mensaje de error en caso de que no se cumpla dicha validación. ##### *Nota:* @@ -107,10 +105,10 @@ Validator ofrece una serie de reglas predefinidas, tratando de cubrir los casos | `minLength` | Valida que la longitud del String no sea menor que la condición | | `minValue` | Valida que el valor del String no sea menor que la condición | | `mustContainMin` | Valida que el String contenga al menos un número mínimo de caracteres incluidos en la condición | -| `mustContainOne` | Valida que el String contenga al menos un carácter incluido en la condición | +| `mustContainOne` | Valida que el String contenga al menos un caracter incluido en la condición | | `name` | Valida que el String sea un nombre propio | -| `notContain` | Valida que el String no contenga ningún carácter incluido en la condición | -| `number` | Valida que el String sea un formato númerico | +| `notContain` | Valida que el String no contenga ningún caracter incluido en la condición | +| `number` | Valida que el String sea un formato numérico | | `numberPattern` | Valida que el String coincida con el patrón, reemplazando las x con números | | `onlyAlphanumeric` | Valida que el String contenga solo caracteres alfanuméricos | | `onlyLetters` | Valida que el String contenga solo letras | @@ -118,7 +116,7 @@ Validator ofrece una serie de reglas predefinidas, tratando de cubrir los casos | `rangeLength` | Valida que la longitud del String esté en el rango establecido | | `rangeValue` | Valida que el valor del String esté en el rango establecido | | `regExp` | Valida que el String coincida con la expresión regular | -| `required` | Valida que el String sea diferente de nulo y vacío. | +| `required` | Valida que el String sea diferente de nulo y vacío | | `shouldOnlyContain` | Valida que el String solo contenga caracteres incluidos en la condición | | `time` | Valida que el String sea un formato de hora | | `time12` | Valida que el String sea una hora con formato de 12 horas | @@ -164,10 +162,10 @@ Validator también ofrece el conjunto de reglas predefinidas en forma de anotaci | `@MinLength` | Valida que la longitud del String no sea menor que la condición | | `@MinValue` | Valida que el valor del String no sea menor que la condición | | `@MustContainMin` | Valida que el String contenga al menos un número mínimo de caracteres incluidos en la condición | -| `@MustContainOne` | Valida que el String contenga al menos un carácter incluido en la condición | +| `@MustContainOne` | Valida que el String contenga al menos un caracter incluido en la condición | | `@Mame` | Valida que el String sea un nombre propio | -| `@MotContain` | Valida que el String no contenga ningún carácter incluido en la condición | -| `@Number` | Valida que el String sea un formato númerico | +| `@MotContain` | Valida que el String no contenga ningún caracter incluido en la condición | +| `@Number` | Valida que el String sea un formato numérico | | `@MumberPattern` | Valida que el String coincida con el patrón, reemplazando las x con números | | `@OnlyAlphanumeric` | Valida que el String contenga solo caracteres alfanuméricos | | `@OnlyLetters` | Valida que el String contenga solo letras | @@ -207,11 +205,11 @@ public class HelloValidator { ``` #### *Nota:* - - Las anotaciones simplifican el encadenamiento de reglas, pero no permite agregar reglas personalizadas. +- Las anotaciones simplifican el encadenamiento de reglas, pero no permite agregar reglas personalizadas. ### Mensajes predeterminados -Los mensajes en las reglas predefinidas y en las anotaciones son opcionales, por lo cual se puede simplificar las +Los mensajes en las reglas predefinidas y en las anotaciones son opcionales, por lo cual se pueden simplificar las implementaciones de las mismas de la siguiente manera. #### Encadenamiento de reglas: @@ -253,7 +251,7 @@ para los mensajes en español, ambas clases implementan la interfaz `Messages`. |---------------------|----------------------------------------------------------|-----------------------------------------------------------| | `compare` | Not match | No coinciden | | `date` | The date does not match the format %s | La fecha no coincide con el formato %s | -| `email` | Email invalid | Correo electrónico invalido | +| `email` | Email invalid | Correo electrónico inválido | | `expirationDate` | Expired date | Fecha expirada | | `httpLink` | Invalid http link | Enlace http inválido | | `httpsLink` | Invalid https link | Enlace https inválido | @@ -269,13 +267,13 @@ para los mensajes en español, ambas clases implementan la interfaz `Messages`. | `minValue` | The value cannot be less than %1$.2f | El valor no puede ser menor a %1$.2f | | `mustContainMin` | At least %d of the following characters are required: %s | Se requiere al menos %d de los siguientes caracteres: %s | | `mustContainOne` | At least one of the following characters is required: %s | Se requiere al menos uno de los siguientes caracteres: %s | -| `name` | Debe introducir un nombre personal válido | Debe introducir un nombre personal válido | +| `name` | Must enter a valid personal name | Debe introducir un nombre personal válido | | `notContain` | The following characters aren't admitted %s | No se admiten los siguientes caracteres %s | | `number` | It is not a number | No es un número | | `numberPattern` | Does not match pattern %s | No coincide con el patrón %s | | `onlyAlphanumeric` | Just alphanumeric characters | Solo caracteres alfanuméricos | | `onlyLetters` | Only letters | Solo letras | -| `onlyNumbers` | Just numbers | Solo números | +| `onlyNumbers` | Only numbers | Solo números | | `rangeLength` | The text must contain between %d to %d characters | El texto debe contener entre %d a %d caracteres | | `rangeValue` | The value must be between %1$.2f and %1$.2f | El valor debe estar entre %1$.2f y %1$.2f | | `regExp` | The value does not match the regular expression %s | El valor no coincide con la expresión regular %s | @@ -327,7 +325,7 @@ public class HelloValidator { ``` En caso de querer comparar dos String, *lo cual es muy útil para validar contraseñas*, se puede hacer uso del método -`.compare`, Opcionalmente se puede utilizar el método `.setNotMatchMessage` para definir el mensaje de error en caso de +`.compare`. Opcionalmente, se puede utilizar el método `.setNotMatchMessage` para definir el mensaje de error en caso de no coincidir. ```java @@ -379,7 +377,7 @@ Si se prefiere no utilizar el evento `.onInvalidEvaluation`, se puede usar los m `.compareOrFail` en sustitución de los métodos `.isValid` y `.comapre` respectivamente. La principal diferencia es que estos métodos no retorna valor alguno y en caso de fallar, arrojan una excepción del tipo -`InvalidEvaluationException` que contiene el mensaje de error de la regla junto con el valor del String a evaluado. +`InvalidEvaluationException` que contiene el mensaje de error de la regla junto con el valor del String evaluado. ```java import io.github.ApamateSoft.validator.Validator; @@ -407,7 +405,7 @@ public class HelloValidator { #### Trabajando con anotaciones Validar un String utilizando anotaciones es muy similar, a trabajar con excepciones, pero en lugar de utilizar los -métodos `.validOrFail` o `.compareOrFail`, se debe utilizar el método estático `Validator.validOrFail`, y se debe pasar +métodos `.validOrFail` o `.compareOrFail`, se debe utilizar el método estático `Validator.validOrFail`, y se debe pasar como parámetro la clase que contiene los atributos a evaluar. ```java @@ -437,8 +435,8 @@ class HelloValidator { ### Alfabetos -Algunas reglas requieren como parámetro un conjunto de caracteres que pueden ser o no requeridos para la validación. A -dicho conjunto se le nombra como alfabeto y validator ofrece un conjunto de los alfabetos como constantes en la clase +Algunas reglas requieren como parámetro un conjunto de caracteres que pueden ser o no requeridos para la validación. A +dicho conjunto se le nombra como alfabeto y validator ofrece un conjunto de los alfabetos como constantes en la clase llamada `Alphabets`. | Nombre | Alfabeto | @@ -458,7 +456,7 @@ llamada `Alphabets`. ### Expresiones regulares -Algunas reglas como en el caso de `regExp`, se le puede pasar como parámetro una expresión regular. Validator también +Algunas reglas como en el caso de `regExp`, se le puede pasar como parámetro una expresión regular. Validator también ofrece una clase con un conjunto de expresiones regulares como constantes en la clase `RegularExpressions`. | Expresión regular | Coincide para | @@ -481,7 +479,7 @@ ofrece una clase con un conjunto de expresiones regulares como constantes en la ### Validadores -Todas las reglas utilizan validadores simples para validar si el String a evaluar es válido o no. Estos validadores son +Todas las reglas utilizan validadores simples para validar si el String a evaluar es válido o no. Estos validadores son métodos estáticos pertenecientes a la clase `Validators` que solo retornan un valor booleano. | Validador | Descripción | @@ -502,10 +500,10 @@ métodos estáticos pertenecientes a la clase `Validators` que solo retornan un | `minLength` | Valida que la longitud del String no sea menor que la condición | | `minValue` | Valida que el valor del String no sea menor que la condición | | `mustContainMin` | Valida que el String contenga al menos un número mínimo de caracteres incluidos en la condición | -| `mustContainOne` | Valida que el String contenga al menos un carácter incluido en la condición | +| `mustContainOne` | Valida que el String contenga al menos un caracter incluido en la condición | | `name` | Valida que el String sea un nombre propio | -| `notContain` | Valida que el String no contenga ningún carácter incluido en la condición | -| `number` | Valida que el String sea un formato númerico | +| `notContain` | Valida que el String no contenga ningún caracter incluido en la condición | +| `number` | Valida que el String sea un formato numérico | | `numberPattern` | Valida que el String coincida con el patrón, reemplazando las x con números | | `onlyAlphanumeric` | Valida que el String contenga solo caracteres alfanuméricos | | `onlyLetters` | Valida que el String contenga solo letras | @@ -563,7 +561,7 @@ public class Register { private String email, phone, psw, pswConfirmation; - public Login() { + public Register() { emailValidator.onInvalidEvaluation(System.out::println); pswValidator.onInvalidEvaluation(System.out::println); phoneValidator.onInvalidEvaluation(System.out::println); From d478252f0d56c3ec2fcde6b4076bcf9dc97cf9ee Mon Sep 17 00:00:00 2001 From: ApamateSoft Date: Sun, 16 Apr 2023 19:21:58 -0400 Subject: [PATCH 2/2] fix pom --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index c27c88c..8bed1c4 100644 --- a/pom.xml +++ b/pom.xml @@ -72,9 +72,6 @@ ossrh https://s01.oss.sonatype.org/ true - - -