From d8c8faaabb23786e026e4cd27fc3db3b43704d56 Mon Sep 17 00:00:00 2001 From: Artem Boiarshinov Date: Sun, 20 Dec 2020 22:47:52 +0400 Subject: [PATCH] HV-1822 add russian specific INN annotation --- .../ap/internal/util/ConstraintHelper.java | 1 + .../validator/ap/internal/util/TypeNames.java | 1 + documentation/src/main/asciidoc/ch02.asciidoc | 5 + .../validator/cfg/defs/ru/INNDef.java | 25 +++ .../validator/cfg/defs/ru/package-info.java | 13 ++ .../validator/constraints/ru/INN.java | 76 +++++++++ .../constraints/ru/package-info.java | 12 ++ .../hv/ru/INNValidator.java | 157 ++++++++++++++++++ .../metadata/core/BuiltinConstraint.java | 1 + .../metadata/core/ConstraintHelper.java | 6 + .../validator/ValidationMessages.properties | 2 + .../ValidationMessages_cs.properties | 2 + .../ValidationMessages_da.properties | 2 + .../ValidationMessages_de.properties | 2 + .../ValidationMessages_es.properties | 2 + .../ValidationMessages_fr.properties | 2 + .../ValidationMessages_hu.properties | 2 + .../ValidationMessages_it.properties | 2 + .../ValidationMessages_pl.properties | 2 + .../ValidationMessages_pt_BR.properties | 2 + .../ValidationMessages_ro.properties | 2 + .../ValidationMessages_ru.properties | 2 + .../ValidationMessages_uk.properties | 2 + ...ProgrammaticConstraintDefinitionsTest.java | 4 + .../annotations/hv/ru/INNValidatorTest.java | 53 ++++++ .../MessagePropertiesTest.java | 5 + .../PredefinedScopeAllConstraintsTest.java | 8 + .../hv/ru/INNValidatorTest.java | 132 +++++++++++++++ 28 files changed, 525 insertions(+) create mode 100644 engine/src/main/java/org/hibernate/validator/cfg/defs/ru/INNDef.java create mode 100644 engine/src/main/java/org/hibernate/validator/cfg/defs/ru/package-info.java create mode 100644 engine/src/main/java/org/hibernate/validator/constraints/ru/INN.java create mode 100644 engine/src/main/java/org/hibernate/validator/constraints/ru/package-info.java create mode 100644 engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/hv/ru/INNValidator.java create mode 100644 engine/src/test/java/org/hibernate/validator/test/constraints/annotations/hv/ru/INNValidatorTest.java create mode 100644 engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/hv/ru/INNValidatorTest.java diff --git a/annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/ConstraintHelper.java b/annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/ConstraintHelper.java index 0220534d7e..e0c6548fa9 100644 --- a/annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/ConstraintHelper.java +++ b/annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/ConstraintHelper.java @@ -302,6 +302,7 @@ public ConstraintHelper(Types typeUtils, AnnotationApiHelper annotationApiHelper registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.REGON_CHECK, CharSequence.class ); registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NIP_CHECK, CharSequence.class ); registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.PESEL_CHECK, CharSequence.class ); + registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.INN_CHECK, CharSequence.class ); registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NOT_BLANK, CharSequence.class ); registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NOT_EMPTY, TYPES_SUPPORTED_BY_SIZE_AND_NOT_EMPTY_ANNOTATIONS ); registerAllowedTypesForBuiltInConstraint( HibernateValidatorTypes.NORMALIZED, CharSequence.class ); diff --git a/annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/TypeNames.java b/annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/TypeNames.java index b346c4a900..94fc1a4cb4 100644 --- a/annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/TypeNames.java +++ b/annotation-processor/src/main/java/org/hibernate/validator/ap/internal/util/TypeNames.java @@ -78,6 +78,7 @@ public static class HibernateValidatorTypes { public static final String REGON_CHECK = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".pl.REGON"; public static final String NIP_CHECK = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".pl.NIP"; public static final String PESEL_CHECK = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".pl.PESEL"; + public static final String INN_CHECK = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".ru.INN"; public static final String NORMALIZED = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".Normalized"; public static final String NOT_BLANK = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".NotBlank"; public static final String NOT_EMPTY = ORG_HIBERNATE_VALIDATOR_CONSTRAINTS + ".NotEmpty"; diff --git a/documentation/src/main/asciidoc/ch02.asciidoc b/documentation/src/main/asciidoc/ch02.asciidoc index b0a5a16a3f..69d386bdf8 100644 --- a/documentation/src/main/asciidoc/ch02.asciidoc +++ b/documentation/src/main/asciidoc/ch02.asciidoc @@ -768,6 +768,11 @@ Hibernate Validator! Hibernate metadata impact::: None Country::: Poland +`@INN`:: Checks that the annotated character sequence represents a Russian taxpayer identification number (https://ru.wikipedia.org/wiki/%D0%98%D0%B4%D0%B5%D0%BD%D1%82%D0%B8%D1%84%D0%B8%D0%BA%D0%B0%D1%86%D0%B8%D0%BE%D0%BD%D0%BD%D1%8B%D0%B9_%D0%BD%D0%BE%D0%BC%D0%B5%D1%80_%D0%BD%D0%B0%D0%BB%D0%BE%D0%B3%D0%BE%D0%BF%D0%BB%D0%B0%D1%82%D0%B5%D0%BB%D1%8C%D1%89%D0%B8%D0%BA%D0%B0[INN]). Can be applied to both individual and juridical versions of INN + Supported data types::: `CharSequence` + Hibernate metadata impact::: None + Country::: Russia + [TIP] ==== In some cases neither the Jakarta Bean Validation constraints nor the custom constraints provided by diff --git a/engine/src/main/java/org/hibernate/validator/cfg/defs/ru/INNDef.java b/engine/src/main/java/org/hibernate/validator/cfg/defs/ru/INNDef.java new file mode 100644 index 0000000000..1fb464abec --- /dev/null +++ b/engine/src/main/java/org/hibernate/validator/cfg/defs/ru/INNDef.java @@ -0,0 +1,25 @@ +/* + * Hibernate Validator, declare and validate application constraints + * + * License: Apache License, Version 2.0 + * See the license.txt file in the root directory or . + */ +package org.hibernate.validator.cfg.defs.ru; + +import org.hibernate.validator.cfg.ConstraintDef; +import org.hibernate.validator.constraints.ru.INN; + +/** + * @author Artem Boiarshinov + */ +public class INNDef extends ConstraintDef { + + public INNDef() { + super( INN.class ); + } + + public INNDef type(INN.Type type) { + addParameter( "type", type ); + return this; + } +} diff --git a/engine/src/main/java/org/hibernate/validator/cfg/defs/ru/package-info.java b/engine/src/main/java/org/hibernate/validator/cfg/defs/ru/package-info.java new file mode 100644 index 0000000000..d038bc5f04 --- /dev/null +++ b/engine/src/main/java/org/hibernate/validator/cfg/defs/ru/package-info.java @@ -0,0 +1,13 @@ +/* + * Hibernate Validator, declare and validate application constraints + * + * License: Apache License, Version 2.0 + * See the license.txt file in the root directory or . + */ + +/** + *

Russian specific constraint definition classes for programmatic constraint definition API.

+ *

This package is part of the public Hibernate Validator API.

+ */ + +package org.hibernate.validator.cfg.defs.ru; diff --git a/engine/src/main/java/org/hibernate/validator/constraints/ru/INN.java b/engine/src/main/java/org/hibernate/validator/constraints/ru/INN.java new file mode 100644 index 0000000000..03d4bd486d --- /dev/null +++ b/engine/src/main/java/org/hibernate/validator/constraints/ru/INN.java @@ -0,0 +1,76 @@ +/* + * Hibernate Validator, declare and validate application constraints + * + * License: Apache License, Version 2.0 + * See the license.txt file in the root directory or . + */ +package org.hibernate.validator.constraints.ru; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE_USE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.validation.Constraint; +import javax.validation.Payload; +import javax.validation.ReportAsSingleViolation; + +import org.hibernate.validator.constraints.ru.INN.List; + +/** + * Checks that the annotated character sequence is a valid russian taxpayer + * identification number (INN in russian transliteration). + * + * @author Artem Boiarshinov + * @see russian taxpayer identification number + */ +@Documented +@Constraint(validatedBy = {}) +@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE }) +@Retention(RUNTIME) +@Repeatable(List.class) +@ReportAsSingleViolation +public @interface INN { + + String message() default "{org.hibernate.validator.constraints.ru.INN.message}"; + + Class[] groups() default {}; + + Class[] payload() default {}; + + Type type() default Type.ANY; + + /** + * Defines several {@code @INN} annotations on the same element. + */ + @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE }) + @Retention(RUNTIME) + @Documented + public @interface List { + + INN[] value(); + } + + /** + * Defines the INN length. Valid lengths of INN are {@code 12} for individual usage + * and {@code 10} for juridical which are represented as {@link INN.Type#INDIVIDUAL} + * and {@link INN.Type#JURIDICAL} respectively. + *

+ * Using {@link INN.Type#ANY} allows to validate values that could either be personal + * or juridical. + * In such case, INN type would be determined by the length of the corresponding value. + */ + enum Type { + INDIVIDUAL, + JURIDICAL, + ANY + } +} diff --git a/engine/src/main/java/org/hibernate/validator/constraints/ru/package-info.java b/engine/src/main/java/org/hibernate/validator/constraints/ru/package-info.java new file mode 100644 index 0000000000..4d6605b7cf --- /dev/null +++ b/engine/src/main/java/org/hibernate/validator/constraints/ru/package-info.java @@ -0,0 +1,12 @@ +/* + * Hibernate Validator, declare and validate application constraints + * + * License: Apache License, Version 2.0 + * See the license.txt file in the root directory or . + */ + +/** + *

Hibernate Validator Russian constraints.

+ *

This package is part of the public Hibernate Validator API.

+ */ +package org.hibernate.validator.constraints.ru; diff --git a/engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/hv/ru/INNValidator.java b/engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/hv/ru/INNValidator.java new file mode 100644 index 0000000000..5533da1124 --- /dev/null +++ b/engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/hv/ru/INNValidator.java @@ -0,0 +1,157 @@ +/* + * Hibernate Validator, declare and validate application constraints + * + * License: Apache License, Version 2.0 + * See the license.txt file in the root directory or . + */ +package org.hibernate.validator.internal.constraintvalidators.hv.ru; + +import java.util.regex.Pattern; + +import org.hibernate.validator.constraints.ru.INN; +import org.hibernate.validator.internal.util.Contracts; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; + +/** + * Checks that a given character sequence (e.g. string) is a valid INN. + * + * @author Artem Boiarshinov + */ +public class INNValidator implements ConstraintValidator { + + private static final Pattern NUMBERS_ONLY_PATTERN = Pattern.compile( "[0-9]+" ); + private static final int RADIX = 10; + + private INNValidationAlgorithm innValidationAlgorithm; + + @Override + public void initialize(INN constraintAnnotation) { + this.innValidationAlgorithm = INNValidationAlgorithm.from( constraintAnnotation.type() ); + } + + @Override + public boolean isValid(CharSequence innCharSeq, ConstraintValidatorContext context) { + if ( innCharSeq == null ) { + return true; + } + + final String inn = innCharSeq.toString(); + + final boolean hasOnlyNumbers = NUMBERS_ONLY_PATTERN.matcher( inn ).matches(); + if ( !hasOnlyNumbers ) { + return false; + } + + if ( !innValidationAlgorithm.isValidLength( inn.length() ) ) { + return false; + } + + final int[] digits = inn.codePoints().map( symbol -> Character.digit( symbol, RADIX ) ).toArray(); + + return innValidationAlgorithm.isValidChecksum( digits ); + + } + + private interface INNValidationAlgorithm { + boolean isValidLength(int length); + + boolean isValidChecksum(int[] digits); + + static INNValidationAlgorithm from(org.hibernate.validator.constraints.ru.INN.Type type) { + Contracts.assertNotNull( type ); + switch ( type ) { + case JURIDICAL: + return INNValidationAlgorithmImpl.JURIDICAL; + case INDIVIDUAL: + return INNValidationAlgorithmImpl.INDIVIDUAL; + case ANY: + default: + return INNValidationAlgorithmImpl.ANY; + } + } + } + + private enum INNValidationAlgorithmImpl implements INNValidationAlgorithm { + + INDIVIDUAL { + @Override + public boolean isValidLength(int length) { + return 12 == length; + } + + @Override + public boolean isValidChecksum(int[] digits) { + return checkChecksumPersonalINN( digits ); + } + }, + JURIDICAL { + @Override + public boolean isValidLength(int length) { + return 10 == length; + } + + @Override + public boolean isValidChecksum(int[] digits) { + return checkChecksumJuridicalINN( digits ); + } + }, + ANY { + @Override + public boolean isValidLength(int length) { + return 10 == length || 12 == length; + } + + @Override + public boolean isValidChecksum(int[] digits) { + final int length = digits.length; + if ( length == 12 ) { + return checkChecksumPersonalINN( digits ); + } + else if ( length == 10 ) { + return checkChecksumJuridicalINN( digits ); + } + throw new IllegalStateException( "Invalid/unsupported inn value length" ); + } + }; + + private static final int[] INDIVIDUAL_WEIGHTS_11 = { 7, 2, 4, 10, 3, 5, 9, 4, 6, 8 }; + private static final int[] INDIVIDUAL_WEIGHTS_12 = { 3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8 }; + private static final int[] JURIDICAL_WEIGHTS = { 2, 4, 10, 3, 5, 9, 4, 6, 8 }; + + private static final int MOD_11 = 11; + private static final int MOD_10 = 10; + + /** + * Check the digits for personal INN using algorithm from + * Wikipedia. + */ + private static boolean checkChecksumPersonalINN(int[] digits) { + final int checkSum11 = getCheckSum( digits, INDIVIDUAL_WEIGHTS_11 ); + final int checkSum12 = getCheckSum( digits, INDIVIDUAL_WEIGHTS_12 ); + + final boolean isCheckSum11Correct = checkSum11 == digits[digits.length - 2]; + final boolean isCheckSum12Correct = checkSum12 == digits[digits.length - 1]; + + return isCheckSum11Correct && isCheckSum12Correct; + } + + /** + * Check the digits for juridical INN using algorithm from + * Wikipedia. + */ + private static boolean checkChecksumJuridicalINN(int[] digits) { + final int checkSum = getCheckSum( digits, JURIDICAL_WEIGHTS ); + return digits[digits.length - 1] == checkSum; + } + + private static int getCheckSum(int[] digits, int[] weights) { + int sum = 0; + for ( int i = 0; i < weights.length; i++ ) { + sum += digits[i] * weights[i]; + } + return ( sum % MOD_11 ) % MOD_10; + } + } +} diff --git a/engine/src/main/java/org/hibernate/validator/internal/metadata/core/BuiltinConstraint.java b/engine/src/main/java/org/hibernate/validator/internal/metadata/core/BuiltinConstraint.java index 9e2156c6ff..29cbc66cf2 100644 --- a/engine/src/main/java/org/hibernate/validator/internal/metadata/core/BuiltinConstraint.java +++ b/engine/src/main/java/org/hibernate/validator/internal/metadata/core/BuiltinConstraint.java @@ -86,6 +86,7 @@ enum BuiltinConstraint { ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_PL_NIP("org.hibernate.validator.constraints.pl.NIP"), ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_PL_PESEL("org.hibernate.validator.constraints.pl.PESEL"), ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_PL_REGON("org.hibernate.validator.constraints.pl.REGON"), + ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_RU_INN("org.hibernate.validator.constraints.ru.INN"), ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_TIME_DURATION_MAX("org.hibernate.validator.constraints.time.DurationMax"), ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_TIME_DURATION_MIN("org.hibernate.validator.constraints.time.DurationMin"); diff --git a/engine/src/main/java/org/hibernate/validator/internal/metadata/core/ConstraintHelper.java b/engine/src/main/java/org/hibernate/validator/internal/metadata/core/ConstraintHelper.java index ed442dad42..d9f6775e8c 100644 --- a/engine/src/main/java/org/hibernate/validator/internal/metadata/core/ConstraintHelper.java +++ b/engine/src/main/java/org/hibernate/validator/internal/metadata/core/ConstraintHelper.java @@ -50,6 +50,7 @@ import static org.hibernate.validator.internal.metadata.core.BuiltinConstraint.ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_PL_PESEL; import static org.hibernate.validator.internal.metadata.core.BuiltinConstraint.ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_PL_REGON; import static org.hibernate.validator.internal.metadata.core.BuiltinConstraint.ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_RANGE; +import static org.hibernate.validator.internal.metadata.core.BuiltinConstraint.ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_RU_INN; import static org.hibernate.validator.internal.metadata.core.BuiltinConstraint.ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_SCRIPT_ASSERT; import static org.hibernate.validator.internal.metadata.core.BuiltinConstraint.ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_TIME_DURATION_MAX; import static org.hibernate.validator.internal.metadata.core.BuiltinConstraint.ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_TIME_DURATION_MIN; @@ -126,6 +127,7 @@ import org.hibernate.validator.constraints.pl.NIP; import org.hibernate.validator.constraints.pl.PESEL; import org.hibernate.validator.constraints.pl.REGON; +import org.hibernate.validator.constraints.ru.INN; import org.hibernate.validator.constraints.time.DurationMax; import org.hibernate.validator.constraints.time.DurationMin; import org.hibernate.validator.internal.constraintvalidators.bv.AssertFalseValidator; @@ -341,6 +343,7 @@ import org.hibernate.validator.internal.constraintvalidators.hv.pl.NIPValidator; import org.hibernate.validator.internal.constraintvalidators.hv.pl.PESELValidator; import org.hibernate.validator.internal.constraintvalidators.hv.pl.REGONValidator; +import org.hibernate.validator.internal.constraintvalidators.hv.ru.INNValidator; import org.hibernate.validator.internal.constraintvalidators.hv.time.DurationMaxValidator; import org.hibernate.validator.internal.constraintvalidators.hv.time.DurationMinValidator; import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorDescriptor; @@ -797,6 +800,9 @@ private ConstraintHelper(Set enabledBuiltinConstraints) { if ( enabledBuiltinConstraints.contains( ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_PL_REGON ) ) { putBuiltinConstraint( tmpConstraints, REGON.class, REGONValidator.class ); } + if ( enabledBuiltinConstraints.contains( ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_RU_INN ) ) { + putBuiltinConstraint( tmpConstraints, INN.class, INNValidator.class ); + } if ( enabledBuiltinConstraints.contains( ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_SCRIPT_ASSERT ) ) { putBuiltinConstraint( tmpConstraints, ScriptAssert.class, ScriptAssertValidator.class ); } diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages.properties index 81048ae4db..9c1d823b38 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages.properties @@ -49,5 +49,7 @@ org.hibernate.validator.constraints.pl.REGON.message = invalid Po org.hibernate.validator.constraints.pl.NIP.message = invalid VAT Identification Number (NIP) org.hibernate.validator.constraints.pl.PESEL.message = invalid Polish National Identification Number (PESEL) +org.hibernate.validator.constraints.ru.INN.message = invalid Russian taxpayer identification number (INN) + org.hibernate.validator.constraints.time.DurationMax.message = must be shorter than${inclusive == true ? ' or equal to' : ''}${days == 0 ? '' : days == 1 ? ' 1 day' : ' ' += days += ' days'}${hours == 0 ? '' : hours == 1 ? ' 1 hour' : ' ' += hours += ' hours'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 second' : ' ' += seconds += ' seconds'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} org.hibernate.validator.constraints.time.DurationMin.message = must be longer than${inclusive == true ? ' or equal to' : ''}${days == 0 ? '' : days == 1 ? ' 1 day' : ' ' += days += ' days'}${hours == 0 ? '' : hours == 1 ? ' 1 hour' : ' ' += hours += ' hours'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 second' : ' ' += seconds += ' seconds'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_cs.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_cs.properties index 52861936e0..8f5f8f36fd 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_cs.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_cs.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = neplatn\u0 org.hibernate.validator.constraints.pl.NIP.message = neplatn\u00e9 da\u0148ov\u00e9 identifika\u010dn\u00ed \u010d\u00edslo (NIP) org.hibernate.validator.constraints.pl.PESEL.message = neplatn\u00e9 Polsk\u00e9 n\u00e1rodn\u00ed Identifika\u010dn\u00ed \u010d\u00edslo (PESEL) +org.hibernate.validator.constraints.ru.INN.message = neplatn\u00e9 ru\u0161tina Identifika\u010dn\u00ed \u010d\u00edslo pl\u00e1tn\u011b dan\u011b (INN) + org.hibernate.validator.constraints.time.DurationMax.message = mus\u00ed b\u00fdt krat\u0161\u00ed ne\u017e${inclusive == true ? ' nebo rovno hodnot\u011b' : ''}${days == 0 ? '' : days == 1 ? ' 1 den' : ' ' += days += ' dny/\u016f'}${hours == 0 ? '' : hours == 1 ? ' 1 hod' : ' ' += hours += ' hod'}${minutes == 0 ? '' : minutes == 1 ? ' 1 min' : ' ' += minutes += ' min'}${seconds == 0 ? '' : seconds == 1 ? ' 1 s' : ' ' += seconds += ' s'}${millis == 0 ? '' : millis == 1 ? ' 1 ms' : ' ' += millis += ' ms'}${nanos == 0 ? '' : nanos == 1 ? ' 1 ns' : ' ' += nanos += ' ns'} org.hibernate.validator.constraints.time.DurationMin.message = mus\u00ed b\u00fdt del\u0161\u00ed ne\u017e${inclusive == true ? ' nebo rovno hodnot\u011b' : ''}${days == 0 ? '' : days == 1 ? ' 1 den' : ' ' += days += ' dny/\u016f'}${hours == 0 ? '' : hours == 1 ? ' 1 hod' : ' ' += hours += ' hod'}${minutes == 0 ? '' : minutes == 1 ? ' 1 min' : ' ' += minutes += ' min'}${seconds == 0 ? '' : seconds == 1 ? ' 1 s' : ' ' += seconds += ' s'}${millis == 0 ? '' : millis == 1 ? ' 1 ms' : ' ' += millis += ' ms'}${nanos == 0 ? '' : nanos == 1 ? ' 1 ns' : ' ' += nanos += ' ns'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_da.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_da.properties index 48c59415b4..7656f265c8 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_da.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_da.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = ugyldigt po org.hibernate.validator.constraints.pl.NIP.message = ugyldigt momsidentifikationsnummer (NIP) org.hibernate.validator.constraints.pl.PESEL.message = ugyldigt polsk nationalt identifikationsnummer (PESEL) +org.hibernate.validator.constraints.ru.INN.message = ugyldigt russisk skattebetalers identifikationsnummer (INN) + org.hibernate.validator.constraints.time.DurationMax.message = skal v\u00e6re kortere end${inclusive == true ? ' eller lig med' : ''}${days == 0 ? '' : days == 1 ? ' 1 dag' : ' ' += days += ' dage'}${hours == 0 ? '' : hours == 1 ? ' 1 time' : ' ' += hours += ' timer'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minut' : ' ' += minutes += ' minutter'}${seconds == 0 ? '' : seconds == 1 ? ' 1 sekund' : ' ' += seconds += ' sekunder'}${millis == 0 ? '' : millis == 1 ? ' 1 millisekund' : ' ' += millis += ' millisekunder'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nanosekund' : ' ' += nanos += ' nanosekunder'} org.hibernate.validator.constraints.time.DurationMin.message = skal v\u00e6re l\u00e6ngere end${inclusive == true ? ' eller lig med' : ''}${days == 0 ? '' : days == 1 ? ' 1 dag' : ' ' += days += ' dage'}${hours == 0 ? '' : hours == 1 ? ' 1 time' : ' ' += hours += ' timer'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minut' : ' ' += minutes += ' minutter'}${seconds == 0 ? '' : seconds == 1 ? ' 1 sekund' : ' ' += seconds += ' sekunder'}${millis == 0 ? '' : millis == 1 ? ' 1 millisekund' : ' ' += millis += ' millisekunder'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nanosekund' : ' ' += nanos += ' nanosekunder'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_de.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_de.properties index 4197a8a416..5ead1a15af 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_de.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_de.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = ung\u00fcl org.hibernate.validator.constraints.pl.NIP.message = ung\u00fcltige Mehrwertsteueridentifikationsnummer (NIP) org.hibernate.validator.constraints.pl.PESEL.message = ung\u00fcltige polnische nationale Identifikationsnummer (PESEL) +org.hibernate.validator.constraints.ru.INN.message = ung\u00fcltige russisch Steuerzahleridentifikationsnummer (INN) + org.hibernate.validator.constraints.time.DurationMax.message = muss k\u00fcrzer sein als${inclusive == true ? ' oder gleich' : ''}${days == 0 ? '' : days == 1 ? ' 1 Tag' : ' ' += days += ' Tage'}${hours == 0 ? '' : hours == 1 ? ' 1 Stunde' : ' ' += hours += ' Stunden'}${minutes == 0 ? '' : minutes == 1 ? ' 1 Minute' : ' ' += minutes += ' Minuten'}${seconds == 0 ? '' : seconds == 1 ? ' 1 Sekunde' : ' ' += seconds += ' Sekunden'}${millis == 0 ? '' : millis == 1 ? ' 1 Millisekunde' : ' ' += millis += ' Millisekunden'}${nanos == 0 ? '' : nanos == 1 ? ' 1 Nanosekunde' : ' ' += nanos += ' Nanosekunden'} org.hibernate.validator.constraints.time.DurationMin.message = muss gr\u00f6\u00dfer sein als${inclusive == true ? ' oder gleich' : ''}${days == 0 ? '' : days == 1 ? ' 1 Tag' : ' ' += days += ' Tage'}${hours == 0 ? '' : hours == 1 ? ' 1 Stunde' : ' ' += hours += ' Stunden'}${minutes == 0 ? '' : minutes == 1 ? ' 1 Minute' : ' ' += minutes += ' Minuten'}${seconds == 0 ? '' : seconds == 1 ? ' 1 Sekunde' : ' ' += seconds += ' Sekunden'}${millis == 0 ? '' : millis == 1 ? ' 1 Millisekunde' : ' ' += millis += ' Millisekunden'}${nanos == 0 ? '' : nanos == 1 ? ' 1 Nanosekunde' : ' ' += nanos += ' Nanosekunden'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_es.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_es.properties index 50110923a2..9d50dcb5fd 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_es.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_es.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = n\u00famer org.hibernate.validator.constraints.pl.NIP.message = n\u00famero de Identificaci\u00f3n de VAT no v\u00e1lido (NIP) org.hibernate.validator.constraints.pl.PESEL.message = n\u00famero de Identificaci\u00f3n Nacional de Polonia no v\u00e1lido (PESEL) +org.hibernate.validator.constraints.ru.INN.message = n\u00famero de Identificaci\u00f3n de Contribuyente de Rusia no v\u00e1lido (INN) + org.hibernate.validator.constraints.time.DurationMax.message = debe tener una longitud menor que ${inclusive == true ? ' o igual a' : ''}${days == 0 ? '' : days == 1 ? ' 1 day' : ' ' += days += ' days'}${hours == 0 ? '' : hours == 1 ? ' 1 hour' : ' ' += hours += ' hours'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 second' : ' ' += seconds += ' seconds'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} org.hibernate.validator.constraints.time.DurationMin.message = debe tener una longitud mayor que ${inclusive == true ? ' o igual a' : ''}${days == 0 ? '' : days == 1 ? ' 1 day' : ' ' += days += ' days'}${hours == 0 ? '' : hours == 1 ? ' 1 hour' : ' ' += hours += ' hours'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 second' : ' ' += seconds += ' seconds'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_fr.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_fr.properties index c4284e4fc8..85e3c78d6b 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_fr.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_fr.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = num\u00e9r org.hibernate.validator.constraints.pl.NIP.message = num\u00e9ro de TVA non valide (NIP) org.hibernate.validator.constraints.pl.PESEL.message = num\u00e9ro de carte d'identit\u00e9 nationale polonais non valide (PESEL) +org.hibernate.validator.constraints.ru.INN.message = num\u00e9ro d'identification de contribuable russe non valide (INN) + org.hibernate.validator.constraints.time.DurationMax.message = doit \u00eatre plus court que ${inclusive == true ? ' ou \u00e9gal \u00e0 ' : ''}${days == 0 ? '' : days == 1 ? ' 1 jour' : ' ' += days += ' jours'}${hours == 0 ? '' : hours == 1 ? ' 1 heure' : ' ' += hours += ' heures'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 seconde' : ' ' += seconds += ' secondes'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} org.hibernate.validator.constraints.time.DurationMin.message = doit \u00eatre plus long que ${inclusive == true ? ' ou \u00e9gal \u00e0 ' : ''}${days == 0 ? '' : days == 1 ? ' 1 jour' : ' ' += days += ' jours'}${hours == 0 ? '' : hours == 1 ? ' 1 heure' : ' ' += hours += ' heures'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 seconde' : ' ' += seconds += ' secondes'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_hu.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_hu.properties index cb21853d94..26cc3e4c65 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_hu.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_hu.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = \u00e9rv\u org.hibernate.validator.constraints.pl.NIP.message = \u00e9rv\u00e9nytelen \u00c1FA azonos\u00edt\u00f3sz\u00e1m (NIP) org.hibernate.validator.constraints.pl.PESEL.message = \u00e9rv\u00e9nytelen lengyel nemzeti azonos\u00edt\u00f3sz\u00e1m (PESEL) +org.hibernate.validator.constraints.ru.INN.message = \u00e9rv\u00e9nytelen orosz ad\u00f3z\u00f3i azonos\u00edt\u00f3 sz\u00e1m (INN) + org.hibernate.validator.constraints.time.DurationMax.message = r\u00f6videbbnek kell lennie, mint ${inclusive == true ? ' or equal to' : ''}${days == 0 ? '' : days == 1 ? ' 1 day' : ' ' += days += ' days'}${hours == 0 ? '' : hours == 1 ? ' 1 hour' : ' ' += hours += ' hours'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 second' : ' ' += seconds += ' seconds'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} org.hibernate.validator.constraints.time.DurationMin.message = hosszabbnak kell lennie, mint ${inclusive == true ? ' or equal to' : ''}${days == 0 ? '' : days == 1 ? ' 1 day' : ' ' += days += ' days'}${hours == 0 ? '' : hours == 1 ? ' 1 hour' : ' ' += hours += ' hours'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 second' : ' ' += seconds += ' seconds'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_it.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_it.properties index fa39d1e96f..095995313a 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_it.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_it.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = numero ide org.hibernate.validator.constraints.pl.NIP.message = numero identificativo IVA (NIP) non valido org.hibernate.validator.constraints.pl.PESEL.message = numero identificativo nazionale polacco (PESEL) non valido +org.hibernate.validator.constraints.ru.INN.message = numero identificativo contribuente russo (INN) non valido + org.hibernate.validator.constraints.time.DurationMax.message = deve essere inferiore a ${inclusive == true ? ' o uguale a' : ''}${days == 0 ? '' : days == 1 ? ' 1 day' : ' ' += days += ' days'}${hours == 0 ? '' : hours == 1 ? ' 1 hour' : ' ' += hours += ' hours'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 second' : ' ' += seconds += ' seconds'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} org.hibernate.validator.constraints.time.DurationMin.message = deve essere superiore a ${inclusive == true ? ' o uguale a' : ''}${days == 0 ? '' : days == 1 ? ' 1 day' : ' ' += days += ' days'}${hours == 0 ? '' : hours == 1 ? ' 1 hour' : ' ' += hours += ' hours'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minute' : ' ' += minutes += ' minutes'}${seconds == 0 ? '' : seconds == 1 ? ' 1 second' : ' ' += seconds += ' seconds'}${millis == 0 ? '' : millis == 1 ? ' 1 milli' : ' ' += millis += ' millis'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_pl.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_pl.properties index 56afd25f30..76b022b5e8 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_pl.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_pl.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = niepoprawn org.hibernate.validator.constraints.pl.NIP.message = niepoprawny number identyfikacyjny VAT (NIP) org.hibernate.validator.constraints.pl.PESEL.message = niepoprawny polski narodowy numer identyfikacyjny (PESEL) +org.hibernate.validator.constraints.ru.INN.message = niepoprawny numer identyfikacyjny rosyjskiego podatnika (INN) + org.hibernate.validator.constraints.time.DurationMax.message = musi by\u0107 ${inclusive == true ? 'r\u00f3wne lub ' : ''}kr\u00f3tsze ni\u017c${days == 0 ? '' : days == 1 ? ' 1 dzie\u0144' : ' ' += days += ' dni'}${hours == 0 ? '' : hours == 1 ? ' 1 godzina' : ' ' += hours += ' godz.'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minuta' : ' ' += minutes += ' min'}${seconds == 0 ? '' : seconds == 1 ? ' 1 sekunda' : ' ' += seconds += ' s'}${millis == 0 ? '' : millis == 1 ? ' 1 milisekunda' : ' ' += millis += ' ms'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nanosekunda' : ' ' += nanos += ' ns'} org.hibernate.validator.constraints.time.DurationMin.message = musi by\u0107 ${inclusive == true ? 'r\u00f3wne lub ' : ''}d\u0142u\u017csze ni\u017c${days == 0 ? '' : days == 1 ? ' 1 dzie\u0144' : ' ' += days += ' dni'}${hours == 0 ? '' : hours == 1 ? ' 1 godzina' : ' ' += hours += ' godz.'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minuta' : ' ' += minutes += ' min'}${seconds == 0 ? '' : seconds == 1 ? ' 1 sekunda' : ' ' += seconds += ' s'}${millis == 0 ? '' : millis == 1 ? ' 1 milisekunda' : ' ' += millis += ' ms'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nanosekunda' : ' ' += nanos += ' ns'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_pt_BR.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_pt_BR.properties index 8bcaefef53..ed0fd9289e 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_pt_BR.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_pt_BR.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = n\u00famer org.hibernate.validator.constraints.pl.NIP.message = n\u00famero de identifica\u00e7\u00e3o de VAT (NIP) inv\u00e1lido org.hibernate.validator.constraints.pl.PESEL.message = n\u00famero de identifica\u00e7\u00e3o nacional polonesa (PESEL) inv\u00e1lido +org.hibernate.validator.constraints.ru.INN.message = n\u00famero de identifica\u00e7\u00e3o de contribuinte russo (INN) inv\u00e1lido + org.hibernate.validator.constraints.time.DurationMax.message = deve ser menor que${inclusive == true ? ' ou igual a' : ''}${days == 0 ? '' : days == 1 ? ' 1 dia' : ' ' += days += ' dias'}${hours == 0 ? '' : hours == 1 ? ' 1 hora' : ' ' += hours += ' horas'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minuto' : ' ' += minutes += ' minutos'}${seconds == 0 ? '' : seconds == 1 ? ' 1 segundo' : ' ' += seconds += ' segundos'}${millis == 0 ? '' : millis == 1 ? ' 1 mili' : ' ' += millis += ' miliss'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} org.hibernate.validator.constraints.time.DurationMin.message = deve ser maior que${inclusive == true ? ' ou igual a' : ''}${days == 0 ? '' : days == 1 ? ' 1 dia' : ' ' += days += ' dias'}${hours == 0 ? '' : hours == 1 ? ' 1 hora' : ' ' += hours += ' horas'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minuto' : ' ' += minutes += ' minutos'}${seconds == 0 ? '' : seconds == 1 ? ' 1 segundo' : ' ' += seconds += ' segundos'}${millis == 0 ? '' : millis == 1 ? ' 1 mili' : ' ' += millis += ' miliss'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nano' : ' ' += nanos += ' nanos'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_ro.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_ro.properties index 5bbc9185cf..7818429c9a 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_ro.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_ro.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = num\u0103r org.hibernate.validator.constraints.pl.NIP.message = num\u0103r invalid de identificare VAT (NIP) org.hibernate.validator.constraints.pl.PESEL.message = num\u0103r invalid de identificare na\u0163ional polonez (PESEL) +org.hibernate.validator.constraints.ru.INN.message = num\u0103r invalid de identificare contribuabil rus (INN) + org.hibernate.validator.constraints.time.DurationMax.message = trebuie s\u0103 fie mai scurt dec\u00e2t${inclusive == true ? ' sau egal cu' : ''}${days == 0 ? '' : days == 1 ? ' 1 zi' : ' ' += days += ' zile'}${hours == 0 ? '' : hours == 1 ? ' 1 or\u0103' : ' ' += hours += ' ore'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minut' : ' ' += minutes += ' minute'}${seconds == 0 ? '' : seconds == 1 ? ' 1 secund\u0103' : ' ' += seconds += ' secunde'}${millis == 0 ? '' : millis == 1 ? ' 1 milisecund\u0103' : ' ' += millis += ' milisecunde'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nanosecund\u0103' : ' ' += nanos += ' nanosecunde'} org.hibernate.validator.constraints.time.DurationMin.message = trebuie s\u0103 fie mai lung dec\u00e2t${inclusive == true ? ' sau egal cu' : ''}${days == 0 ? '' : days == 1 ? ' 1 zi' : ' ' += days += ' zile'}${hours == 0 ? '' : hours == 1 ? ' 1 or\u0103' : ' ' += hours += ' ore'}${minutes == 0 ? '' : minutes == 1 ? ' 1 minut' : ' ' += minutes += ' minute'}${seconds == 0 ? '' : seconds == 1 ? ' 1 secund\u0103' : ' ' += seconds += ' secunde'}${millis == 0 ? '' : millis == 1 ? ' 1 milisecund\u0103' : ' ' += millis += ' milisecunde'}${nanos == 0 ? '' : nanos == 1 ? ' 1 nanosecund\u0103' : ' ' += nanos += ' nanosecunde'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_ru.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_ru.properties index 20dbee9900..9009eade10 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_ru.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_ru.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = \u041d\u04 org.hibernate.validator.constraints.pl.NIP.message = \u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 VAT (NIP) org.hibernate.validator.constraints.pl.PESEL.message = \u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u043f\u043e\u043b\u044c\u0441\u043a\u0438\u0439 \u043d\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 (PESEL) +org.hibernate.validator.constraints.ru.INN.message = \u041d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043d\u0430\u043b\u043e\u0433\u043e\u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430 (\u0418\u041d\u041d) + org.hibernate.validator.constraints.time.DurationMax.message = \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043a\u043e\u0440\u043e\u0447\u0435${inclusive == true ? ' \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e' : ''}${days == 0 ? '' : days == 1 ? ' 1 \u0434\u043d' : ' ' += days += ' \u0434\u043d'}${hours == 0 ? '' : hours == 1 ? ' 1 \u0447' : ' ' += hours += ' \u0447'}${minutes == 0 ? '' : minutes == 1 ? ' 1 \u043c\u0438\u043d' : ' ' += minutes += ' \u043c\u0438\u043d'}${seconds == 0 ? '' : seconds == 1 ? ' 1 \u0441' : ' ' += seconds += ' \u0441'}${millis == 0 ? '' : millis == 1 ? ' 1 \u043c\u0441' : ' ' += millis += ' \u043c\u0441'}${nanos == 0 ? '' : nanos == 1 ? ' 1 \u043d\u0441' : ' ' += nanos += ' \u043d\u0441'} org.hibernate.validator.constraints.time.DurationMin.message = \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u043b\u0438\u043d\u043d\u0435\u0435${inclusive == true ? ' \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e' : ''}${days == 0 ? '' : days == 1 ? ' 1 \u0434\u043d' : ' ' += days += ' \u0434\u043d'}${hours == 0 ? '' : hours == 1 ? ' 1 \u0447' : ' ' += hours += ' \u0447'}${minutes == 0 ? '' : minutes == 1 ? ' 1 \u043c\u0438\u043d' : ' ' += minutes += ' \u043c\u0438\u043d'}${seconds == 0 ? '' : seconds == 1 ? ' 1 \u0441' : ' ' += seconds += ' \u0441'}${millis == 0 ? '' : millis == 1 ? ' 1 \u043c\u0441' : ' ' += millis += ' \u043c\u0441'}${nanos == 0 ? '' : nanos == 1 ? ' 1 \u043d\u0441' : ' ' += nanos += ' \u043d\u0441'} diff --git a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_uk.properties b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_uk.properties index 31b6790ac3..9778e08ed1 100644 --- a/engine/src/main/resources/org/hibernate/validator/ValidationMessages_uk.properties +++ b/engine/src/main/resources/org/hibernate/validator/ValidationMessages_uk.properties @@ -48,5 +48,7 @@ org.hibernate.validator.constraints.pl.REGON.message = \u043d\u0435\u043f\u0 org.hibernate.validator.constraints.pl.NIP.message = \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0438\u0439 \u0456\u0434\u0435\u043d\u0442\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0439\u043d\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u043e\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u043b\u0430\u0442\u043d\u0438\u043a\u0430 \u043f\u043e\u0434\u0430\u0442\u043a\u0443 \u041f\u0414\u0412 (NIP) org.hibernate.validator.constraints.pl.PESEL.message = \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0438\u0439 \u043f\u043e\u043b\u044c\u0441\u043a\u0438\u0439 \u043d\u0430\u0446\u0456\u043e\u043d\u0430\u043b\u044c\u043d\u0438\u0439 \u0456\u0434\u0435\u043d\u0442\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0439\u043d\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 (PESEL) +org.hibernate.validator.constraints.ru.INN.message = \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0438\u0439 \u0456\u0434\u0435\u043d\u0442\u0438\u0444\u0456\u043a\u0430\u0446\u0456\u0439\u043d\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u043f\u043b\u0430\u0442\u043d\u0438\u043a\u0430 \u043f\u043e\u0434\u0430\u0442\u043a\u0456\u0432 (INN) + org.hibernate.validator.constraints.time.DurationMax.message = \u043c\u0430\u0454 \u0431\u0443\u0442\u0438 \u043a\u043e\u0440\u043e\u0442\u0448\u0438\u0439${inclusive == true ? ' \u0430\u0431\u043e \u0440\u0456\u0432\u043d\u0438\u0439' : ''} \u0437\u0430${days == 0 ? '' : days == 1 ? ' 1 \u0434\u0435\u043d\u044c' : ' ' += days += ' \u0434\u043d\u0456\u0432'}${hours == 0 ? '' : hours == 1 ? ' 1 \u0433\u043e\u0434\u0438\u043d\u0430' : ' ' += hours += ' \u0433\u043e\u0434\u0438\u043d'}${minutes == 0 ? '' : minutes == 1 ? ' 1 \u0445\u0432\u0438\u043b\u0438\u043d\u0430' : ' ' += minutes += ' \u0445\u0432\u0438\u043b\u0438\u043d'}${seconds == 0 ? '' : seconds == 1 ? ' 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0430' : ' ' += seconds += ' \u0441\u0435\u043a\u0443\u043d\u0434'}${millis == 0 ? '' : millis == 1 ? ' 1 \u043c\u0456\u043b\u0456\u0441\u0435\u043a\u0443\u043d\u0434\u0430' : ' ' += millis += ' \u043c\u0456\u043b\u0456\u0441\u0435\u043a\u0443\u043d\u0434'}${nanos == 0 ? '' : nanos == 1 ? ' 1 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430' : ' ' += nanos += ' \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434'} org.hibernate.validator.constraints.time.DurationMin.message = \u043c\u0430\u0454 \u0431\u0443\u0442\u0438 \u0434\u043e\u0432\u0448\u0438\u0439${inclusive == true ? ' \u0430\u0431\u043e \u0440\u0456\u0432\u043d\u0438\u0439' : ''} \u0437\u0430${days == 0 ? '' : days == 1 ? ' 1 \u0434\u0435\u043d\u044c' : ' ' += days += ' \u0434\u043d\u0456\u0432'}${hours == 0 ? '' : hours == 1 ? ' 1 \u0433\u043e\u0434\u0438\u043d\u0430' : ' ' += hours += ' \u0433\u043e\u0434\u0438\u043d'}${minutes == 0 ? '' : minutes == 1 ? ' 1 \u0445\u0432\u0438\u043b\u0438\u043d\u0430' : ' ' += minutes += ' \u0445\u0432\u0438\u043b\u0438\u043d'}${seconds == 0 ? '' : seconds == 1 ? ' 1 \u0441\u0435\u043a\u0443\u043d\u0434\u0430' : ' ' += seconds += ' \u0441\u0435\u043a\u0443\u043d\u0434'}${millis == 0 ? '' : millis == 1 ? ' 1 \u043c\u0456\u043b\u0456\u0441\u0435\u043a\u0443\u043d\u0434\u0430' : ' ' += millis += ' \u043c\u0456\u043b\u0456\u0441\u0435\u043a\u0443\u043d\u0434'}${nanos == 0 ? '' : nanos == 1 ? ' 1 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430' : ' ' += nanos += ' \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434'} diff --git a/engine/src/test/java/org/hibernate/validator/test/cfg/ProgrammaticConstraintDefinitionsTest.java b/engine/src/test/java/org/hibernate/validator/test/cfg/ProgrammaticConstraintDefinitionsTest.java index 790b7f3871..31399256dc 100644 --- a/engine/src/test/java/org/hibernate/validator/test/cfg/ProgrammaticConstraintDefinitionsTest.java +++ b/engine/src/test/java/org/hibernate/validator/test/cfg/ProgrammaticConstraintDefinitionsTest.java @@ -32,6 +32,7 @@ import org.hibernate.validator.cfg.defs.pl.NIPDef; import org.hibernate.validator.cfg.defs.pl.PESELDef; import org.hibernate.validator.cfg.defs.pl.REGONDef; +import org.hibernate.validator.cfg.defs.ru.INNDef; import org.hibernate.validator.constraints.LuhnCheck; import org.hibernate.validator.constraints.br.CNPJ; import org.hibernate.validator.constraints.br.CPF; @@ -39,6 +40,7 @@ import org.hibernate.validator.constraints.pl.NIP; import org.hibernate.validator.constraints.pl.PESEL; import org.hibernate.validator.constraints.pl.REGON; +import org.hibernate.validator.constraints.ru.INN; import org.hibernate.validator.testutil.PrefixableParameterNameProvider; import org.testng.annotations.Test; @@ -60,6 +62,8 @@ public void countrySpecificProgrammaticDefinition() { doProgrammaticTest( PESEL.class, new PESELDef(), "12252918020", "44051401358", "invalid Polish National Identification Number (PESEL)" ); doProgrammaticTest( NIP.class, new NIPDef(), "1786052059", "2596048505", "invalid VAT Identification Number (NIP)" ); + doProgrammaticTest( INN.class, new INNDef().type( INN.Type.INDIVIDUAL ), "127530851622", "127530851623", "invalid Russian taxpayer identification number (INN)" ); + doProgrammaticTest( INN.class, new INNDef().type( INN.Type.JURIDICAL ), "8606995694", "8606995695", "invalid Russian taxpayer identification number (INN)" ); } @Test diff --git a/engine/src/test/java/org/hibernate/validator/test/constraints/annotations/hv/ru/INNValidatorTest.java b/engine/src/test/java/org/hibernate/validator/test/constraints/annotations/hv/ru/INNValidatorTest.java new file mode 100644 index 0000000000..4d51429b3a --- /dev/null +++ b/engine/src/test/java/org/hibernate/validator/test/constraints/annotations/hv/ru/INNValidatorTest.java @@ -0,0 +1,53 @@ +/* + * Hibernate Validator, declare and validate application constraints + * + * License: Apache License, Version 2.0 + * See the license.txt file in the root directory or . + */ +package org.hibernate.validator.test.constraints.annotations.hv.ru; + +import static org.hibernate.validator.testutil.ConstraintViolationAssert.assertNoViolations; +import static org.hibernate.validator.testutil.ConstraintViolationAssert.assertThat; +import static org.hibernate.validator.testutil.ConstraintViolationAssert.violationOf; + +import java.util.Set; + +import org.hibernate.validator.constraints.ru.INN; +import org.hibernate.validator.test.constraints.annotations.AbstractConstrainedTest; + +import javax.validation.ConstraintViolation; +import org.testng.annotations.Test; + +/** + * Test to make sure that elements annotated with {@link INN} are validated. + * + * @author Artem Boiarshinov + */ +public class INNValidatorTest extends AbstractConstrainedTest { + + @Test + public void testINN() { + final Person person = new Person( "245885856020" ); + final Set> violations = validator.validate( person ); + assertNoViolations( violations ); + } + + @Test + public void testINNInvalid() { + final Person person = new Person( "0123456789" ); + final Set> violations = validator.validate( person ); + assertThat( violations ).containsOnlyViolations( + violationOf( INN.class ).withMessage( "invalid Russian taxpayer identification number (INN)" ) + ); + } + + private static class Person { + + @INN + private final String inn; + + public Person(String inn) { + this.inn = inn; + } + } +} diff --git a/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/MessagePropertiesTest.java b/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/MessagePropertiesTest.java index 0ad6a0a177..dc28661d56 100644 --- a/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/MessagePropertiesTest.java +++ b/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/MessagePropertiesTest.java @@ -68,6 +68,7 @@ import org.hibernate.validator.constraints.pl.NIP; import org.hibernate.validator.constraints.pl.PESEL; import org.hibernate.validator.constraints.pl.REGON; +import org.hibernate.validator.constraints.ru.INN; import org.hibernate.validator.constraints.time.DurationMax; import org.hibernate.validator.constraints.time.DurationMin; import org.hibernate.validator.testutil.ConstraintViolationAssert; @@ -169,6 +170,7 @@ public void testMessageProperties() throws NoSuchMethodException, SecurityExcept violationOf( REGON.class ), violationOf( NIP.class ), violationOf( PESEL.class ), + violationOf( INN.class ), violationOf( DurationMax.class ), violationOf( DurationMin.class ), violationOf( ScriptAssert.class ) @@ -344,6 +346,9 @@ private static class Bean { @PESEL private String pesel = "invalid"; + @INN + private String inn = "invalid"; + @DurationMax(days = 4, hours = 4, minutes = 4, millis = 4, nanos = 4) private Duration durationMax = Duration.ofDays( 8 ); diff --git a/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/PredefinedScopeAllConstraintsTest.java b/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/PredefinedScopeAllConstraintsTest.java index 497c3200c6..8826217afc 100644 --- a/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/PredefinedScopeAllConstraintsTest.java +++ b/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/PredefinedScopeAllConstraintsTest.java @@ -67,6 +67,7 @@ import org.hibernate.validator.constraints.pl.NIP; import org.hibernate.validator.constraints.pl.PESEL; import org.hibernate.validator.constraints.pl.REGON; +import org.hibernate.validator.constraints.ru.INN; import org.hibernate.validator.constraints.time.DurationMax; import org.hibernate.validator.constraints.time.DurationMin; import org.hibernate.validator.testutil.ConstraintViolationAssert; @@ -128,6 +129,7 @@ public void testConstraints() throws NoSuchMethodException, SecurityException { testConstraint( REGON.class, new REGONBean() ); testConstraint( NIP.class, new NIPBean() ); testConstraint( PESEL.class, new PESELBean() ); + testConstraint( INN.class, new INNBean() ); testConstraint( DurationMax.class, new DurationMaxBean() ); testConstraint( DurationMin.class, new DurationMinBean() ); testConstraint( ScriptAssert.class, new ScriptAssertBean() ); @@ -429,6 +431,12 @@ private static class PESELBean { private String pesel = "invalid"; } + private static class INNBean { + + @INN + private String inn = "invalid"; + } + private static class DurationMaxBean { @DurationMax(days = 4, hours = 4, minutes = 4, millis = 4, nanos = 4) diff --git a/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/hv/ru/INNValidatorTest.java b/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/hv/ru/INNValidatorTest.java new file mode 100644 index 0000000000..24ff8691ed --- /dev/null +++ b/engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/hv/ru/INNValidatorTest.java @@ -0,0 +1,132 @@ +/* + * Hibernate Validator, declare and validate application constraints + * + * License: Apache License, Version 2.0 + * See the license.txt file in the root directory or . + */ +package org.hibernate.validator.test.internal.constraintvalidators.hv.ru; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import org.hibernate.validator.constraints.ru.INN; +import org.hibernate.validator.internal.constraintvalidators.hv.ru.INNValidator; +import org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor; + +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** + * A set of tests for {@link INN} constraint validator ({@link INNValidator}), + * which make sure that validation is performed correctly. + * + * @author Artem Boiarshinov + * @see fake INN generator + */ +public class INNValidatorTest { + + private INNValidator validator; + + @BeforeMethod + public void setUp() { + validator = new INNValidator(); + } + + @Test + public void validIndividualTypeINN() { + validator.initialize( initializeAnnotation( INN.Type.INDIVIDUAL ) ); + + assertValidINN( null ); + assertValidINN( "246964567008" ); + assertValidINN( "356393289962" ); + assertValidINN( "279837166431" ); + assertValidINN( "827175083460" ); + assertValidINN( "789429596404" ); + assertValidINN( "929603416330" ); + assertValidINN( "086229647992" ); + } + + @Test + public void invalidIndividualTypeINN() { + validator.initialize( initializeAnnotation( INN.Type.INDIVIDUAL ) ); + + //invalid checksum + assertInvalidINN( "012345678912" ); + assertInvalidINN( "246964567009" ); + + //invalid symbols + assertInvalidINN( "a46964567008" ); + + //invalid length + assertInvalidINN( "" ); + assertInvalidINN( "90660563173" ); + assertInvalidINN( "9066056317378" ); + + //invalid type + assertInvalidINN( "4546366155" ); + } + + @Test + public void validJuridicalTypeINN() { + validator.initialize( initializeAnnotation( INN.Type.JURIDICAL ) ); + + assertValidINN( null ); + assertValidINN( "0305773929" ); + assertValidINN( "5496344268" ); + assertValidINN( "0314580754" ); + assertValidINN( "8652697156" ); + assertValidINN( "3527694367" ); + assertValidINN( "8771236130" ); + assertValidINN( "9254906927" ); + } + + @Test + public void invalidJuridicalTypeINN() { + validator.initialize( initializeAnnotation( INN.Type.JURIDICAL ) ); + + //invalid checksum + assertInvalidINN( "0123456789" ); + assertInvalidINN( "0305773928" ); + + //invalid symbols + assertInvalidINN( "a305773929" ); + + //invalid length + assertInvalidINN( "" ); + assertInvalidINN( "906605631" ); + assertInvalidINN( "90660563173" ); + + //invalid type + assertInvalidINN( "246964567008" ); + } + + @Test + public void testAnyTypeINN() { + validator.initialize( initializeAnnotation( INN.Type.ANY ) ); + + final String personalValidINN = "246964567008"; + final String juridicalValidINN = "5496344268"; + final String personalInvalidINN = "246964567009"; + final String juridicalInvalidINN = "0305773928"; + + assertValidINN( null ); + assertValidINN( personalValidINN ); + assertValidINN( juridicalValidINN ); + assertInvalidINN( personalInvalidINN ); + assertInvalidINN( juridicalInvalidINN ); + } + + private void assertValidINN(String inn) { + assertTrue( validator.isValid( inn, null ), inn + " should be a valid INN" ); + } + + private void assertInvalidINN(String inn) { + assertFalse( validator.isValid( inn, null ), inn + " should be a invalid INN" ); + } + + private INN initializeAnnotation(INN.Type type) { + ConstraintAnnotationDescriptor.Builder descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<>( INN.class ); + descriptorBuilder.setAttribute( "type", type ); + return descriptorBuilder.build().getAnnotation(); + } +}