├── .github ├── dependabot.yml └── workflows │ └── bval-ci.yml ├── .gitignore ├── CHANGES.txt ├── LICENSE ├── NOTICE ├── README.md ├── README.txt ├── RELEASE-NOTES.adoc ├── bval-bundle └── pom.xml ├── bval-extras ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── apache │ │ └── bval │ │ └── extras │ │ └── constraints │ │ ├── checkdigit │ │ ├── ABANumber.java │ │ ├── ABANumberValidator.java │ │ ├── CUSIP.java │ │ ├── CUSIPValidator.java │ │ ├── EAN13.java │ │ ├── EAN13Validator.java │ │ ├── IBAN.java │ │ ├── IBANValidator.java │ │ ├── ISBN10.java │ │ ├── ISBN10Validator.java │ │ ├── Luhn.java │ │ ├── LuhnValidator.java │ │ ├── ModulusValidator.java │ │ ├── Sedol.java │ │ ├── SedolValidator.java │ │ ├── Verhoeff.java │ │ ├── VerhoeffValidator.java │ │ └── package-info.java │ │ ├── creditcard │ │ ├── AmericanExpress.java │ │ ├── Diners.java │ │ ├── Discover.java │ │ ├── Mastercard.java │ │ ├── Visa.java │ │ └── package-info.java │ │ ├── file │ │ ├── Directory.java │ │ ├── DirectoryValidator.java │ │ ├── NotDirectory.java │ │ ├── NotDirectoryValidator.java │ │ ├── Symlink.java │ │ ├── SymlinkValidator.java │ │ └── package-info.java │ │ ├── net │ │ ├── Domain.java │ │ ├── DomainValidator.java │ │ ├── InetAddress.java │ │ ├── InetAddressValidator.java │ │ └── package-info.java │ │ └── package-info.java │ └── test │ └── java │ └── org │ └── apache │ └── bval │ └── extras │ └── constraints │ ├── checkdigit │ ├── ABANumberValidatorTest.java │ ├── AbstractCheckDigitTest.java │ ├── CUSIPValidatorTest.java │ ├── EAN13CheckDigitTest.java │ ├── IBANCheckDigitTest.java │ ├── ISBN10CheckDigitTest.java │ ├── LuhnCheckDigitTest.java │ ├── SedolCheckDigitTest.java │ └── VerhoeffCheckDigitTest.java │ └── net │ ├── DomainValidatorTest.java │ └── InetAddressValidatorTest.java ├── bval-jsr ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── bval │ │ │ ├── cdi │ │ │ ├── AnyLiteral.java │ │ │ ├── BValAnnotatedType.java │ │ │ ├── BValBinding.java │ │ │ ├── BValExtension.java │ │ │ ├── BValInterceptor.java │ │ │ ├── BValInterceptorBean.java │ │ │ ├── DefaultLiteral.java │ │ │ ├── EmptyAnnotationLiteral.java │ │ │ ├── ValidatorBean.java │ │ │ └── ValidatorFactoryBean.java │ │ │ ├── constraints │ │ │ ├── AbstractPatternValidator.java │ │ │ ├── AssertFalseValidator.java │ │ │ ├── AssertTrueValidator.java │ │ │ ├── DecimalMaxValidator.java │ │ │ ├── DecimalMinValidator.java │ │ │ ├── DigitsValidatorForNumber.java │ │ │ ├── DigitsValidatorForString.java │ │ │ ├── Email.java │ │ │ ├── EmailValidator.java │ │ │ ├── FutureOrPresentValidator.java │ │ │ ├── FutureValidator.java │ │ │ ├── MaxValidatorForNumber.java │ │ │ ├── MaxValidatorForString.java │ │ │ ├── MinValidatorForNumber.java │ │ │ ├── MinValidatorForString.java │ │ │ ├── NotBlankValidator.java │ │ │ ├── NotEmpty.java │ │ │ ├── NotEmptyValidator.java │ │ │ ├── NotEmptyValidatorForCharSequence.java │ │ │ ├── NotEmptyValidatorForCollection.java │ │ │ ├── NotEmptyValidatorForMap.java │ │ │ ├── NotNullValidator.java │ │ │ ├── NullValidator.java │ │ │ ├── NumberSignValidator.java │ │ │ ├── PastOrPresentValidator.java │ │ │ ├── PastValidator.java │ │ │ ├── PatternValidator.java │ │ │ ├── SizeValidator.java │ │ │ └── TimeValidator.java │ │ │ ├── el │ │ │ ├── ELFacade.java │ │ │ └── MessageEvaluator.java │ │ │ ├── jsr │ │ │ ├── ApacheFactoryContext.java │ │ │ ├── ApacheMessageContext.java │ │ │ ├── ApacheValidationProvider.java │ │ │ ├── ApacheValidatorConfiguration.java │ │ │ ├── ApacheValidatorFactory.java │ │ │ ├── BootstrapConfigurationImpl.java │ │ │ ├── CascadingPropertyValidator.java │ │ │ ├── ConfigurationImpl.java │ │ │ ├── ConstraintAnnotationAttributes.java │ │ │ ├── ConstraintCached.java │ │ │ ├── ConstraintDefaults.java │ │ │ ├── ConstraintViolationImpl.java │ │ │ ├── DefaultConstraintValidatorFactory.java │ │ │ ├── DefaultMessageInterpolator.java │ │ │ ├── DefaultValidationProviderResolver.java │ │ │ ├── GraphContext.java │ │ │ ├── ParticipantFactory.java │ │ │ ├── ValidatorImpl.java │ │ │ ├── descriptor │ │ │ │ ├── BeanD.java │ │ │ │ ├── CascadableContainerD.java │ │ │ │ ├── ComposedD.java │ │ │ │ ├── ConstraintD.java │ │ │ │ ├── ConstructorD.java │ │ │ │ ├── ContainerElementTypeD.java │ │ │ │ ├── CrossParameterD.java │ │ │ │ ├── DescriptorManager.java │ │ │ │ ├── ElementD.java │ │ │ │ ├── ExecutableD.java │ │ │ │ ├── Finder.java │ │ │ │ ├── MetadataReader.java │ │ │ │ ├── MethodD.java │ │ │ │ ├── ParameterD.java │ │ │ │ ├── PropertyD.java │ │ │ │ ├── ReturnValueD.java │ │ │ │ └── package-info.java │ │ │ ├── groups │ │ │ │ ├── Group.java │ │ │ │ ├── GroupConversion.java │ │ │ │ ├── GroupStrategy.java │ │ │ │ ├── Groups.java │ │ │ │ └── GroupsComputer.java │ │ │ ├── job │ │ │ │ ├── ComputeConstraintValidatorClass.java │ │ │ │ ├── ConstraintValidatorContextImpl.java │ │ │ │ ├── ValidateBean.java │ │ │ │ ├── ValidateExecutable.java │ │ │ │ ├── ValidateParameters.java │ │ │ │ ├── ValidateProperty.java │ │ │ │ ├── ValidateReturnValue.java │ │ │ │ ├── ValidationJob.java │ │ │ │ └── ValidationJobFactory.java │ │ │ ├── metadata │ │ │ │ ├── AnnotationBehavior.java │ │ │ │ ├── AnnotationBehaviorMergeStrategy.java │ │ │ │ ├── AnnotationDeclaredValidatorMappingProvider.java │ │ │ │ ├── ClassLoadingValidatorMappingProvider.java │ │ │ │ ├── CompositeBuilder.java │ │ │ │ ├── CompositeValidatorMappingProvider.java │ │ │ │ ├── ContainerElementKey.java │ │ │ │ ├── DualBuilder.java │ │ │ │ ├── DualValidationMappingProvider.java │ │ │ │ ├── EmptyBuilder.java │ │ │ │ ├── HasAnnotationBehavior.java │ │ │ │ ├── HierarchyBuilder.java │ │ │ │ ├── Liskov.java │ │ │ │ ├── Meta.java │ │ │ │ ├── MetadataBuilder.java │ │ │ │ ├── MetadataBuilders.java │ │ │ │ ├── MetadataSource.java │ │ │ │ ├── ReflectionBuilder.java │ │ │ │ ├── Signature.java │ │ │ │ ├── ValidatorMapping.java │ │ │ │ ├── ValidatorMappingProvider.java │ │ │ │ ├── XmlBuilder.java │ │ │ │ └── XmlValidationMappingProvider.java │ │ │ ├── parameter │ │ │ │ └── DefaultParameterNameProvider.java │ │ │ ├── resolver │ │ │ │ ├── CachingRelevant.java │ │ │ │ ├── CachingTraversableResolver.java │ │ │ │ ├── DefaultTraversableResolver.java │ │ │ │ ├── JPATraversableResolver.java │ │ │ │ └── SimpleTraversableResolver.java │ │ │ ├── util │ │ │ │ ├── AnnotationProxy.java │ │ │ │ ├── AnnotationProxyBuilder.java │ │ │ │ ├── AnnotationsManager.java │ │ │ │ ├── ContainerElementNodeBuilderCustomizableContextImpl.java │ │ │ │ ├── ContainerElementNodeBuilderDefinedContextImpl.java │ │ │ │ ├── ContainerElementNodeContextBuilderImpl.java │ │ │ │ ├── ExecutableTypes.java │ │ │ │ ├── IOs.java │ │ │ │ ├── LeafNodeBuilderCustomizableContextImpl.java │ │ │ │ ├── LookBehindRegexHolder.java │ │ │ │ ├── Methods.java │ │ │ │ ├── NodeBuilderCustomizableContextImpl.java │ │ │ │ ├── NodeBuilderDefinedContextImpl.java │ │ │ │ ├── NodeContextBuilderImpl.java │ │ │ │ ├── NodeImpl.java │ │ │ │ ├── PathImpl.java │ │ │ │ ├── PathNavigation.java │ │ │ │ ├── Proxies.java │ │ │ │ └── ToUnmodifiable.java │ │ │ ├── valueextraction │ │ │ │ ├── ExtractValues.java │ │ │ │ ├── FxExtractor.java │ │ │ │ ├── IterableElementExtractor.java │ │ │ │ ├── ListElementExtractor.java │ │ │ │ ├── MapExtractor.java │ │ │ │ ├── OptionalExtractor.java │ │ │ │ └── ValueExtractors.java │ │ │ └── xml │ │ │ │ ├── MappingValidator.java │ │ │ │ ├── SchemaManager.java │ │ │ │ ├── ValidationMappingParser.java │ │ │ │ └── ValidationParser.java │ │ │ ├── routines │ │ │ └── EMailValidationUtils.java │ │ │ └── util │ │ │ ├── BValVersion.java │ │ │ ├── CloseableAble.java │ │ │ ├── CollectionSet.java │ │ │ ├── Comparators.java │ │ │ ├── EmulatedAnnotatedType.java │ │ │ ├── Escapes.java │ │ │ ├── Exceptions.java │ │ │ ├── Lazy.java │ │ │ ├── LazyInt.java │ │ │ ├── ObjectUtils.java │ │ │ ├── ObjectWrapper.java │ │ │ ├── StringUtils.java │ │ │ ├── Validate.java │ │ │ ├── ValidatorUtils.java │ │ │ └── reflection │ │ │ ├── Reflection.java │ │ │ └── TypeUtils.java │ ├── resources │ │ ├── META-INF │ │ │ └── services │ │ │ │ ├── jakarta.enterprise.inject.spi.Extension │ │ │ │ ├── jakarta.validation.spi.ValidationProvider │ │ │ │ └── org.apache.bval.jsr.metadata.MetadataSource │ │ └── org │ │ │ └── apache │ │ │ └── bval │ │ │ └── jsr │ │ │ ├── DefaultConstraints.properties │ │ │ ├── ValidationMessages.properties │ │ │ ├── ValidationMessages_de.properties │ │ │ ├── ValidationMessages_en.properties │ │ │ ├── ValidationMessages_es.properties │ │ │ ├── ValidationMessages_it.properties │ │ │ └── valueextraction │ │ │ └── DefaultExtractors.properties │ ├── xjb │ │ └── binding-customization.xjb │ └── xsd │ │ ├── validation-configuration-1.0.xsd │ │ ├── validation-configuration-1.1.xsd │ │ ├── validation-configuration-2.0.xsd │ │ ├── validation-configuration-3.0.xsd │ │ ├── validation-configuration-3.1.xsd │ │ ├── validation-mapping-1.0.xsd │ │ ├── validation-mapping-1.1.xsd │ │ ├── validation-mapping-2.0.xsd │ │ ├── validation-mapping-3.0.xsd │ │ └── validation-mapping-3.1.xsd │ └── test │ ├── java │ └── org │ │ └── apache │ │ └── bval │ │ ├── constraints │ │ ├── AssertFalseValidatorTest.java │ │ ├── AssertTrueValidatorTest.java │ │ ├── AuthorAddressKnown.java │ │ ├── CompanyEmail.java │ │ ├── DecimalMinMaxValidatorsTest.java │ │ ├── DigitsValidatorTest.java │ │ ├── EmailValidatorTest.java │ │ ├── FrenchZipCode.java │ │ ├── FrenchZipcodeValidator.java │ │ ├── HasStringValidator.java │ │ ├── HasValue.java │ │ ├── MinMaxValidatorsForNumberTest.java │ │ ├── NotNullValidatorTest.java │ │ ├── NullValidatorTest.java │ │ ├── Password.java │ │ ├── ZipCodeCityCoherence.java │ │ └── ZipCodeCityCoherenceValidator.java │ │ └── jsr │ │ ├── BeanDescriptorTest.java │ │ ├── BootstrapTest.java │ │ ├── CircularReferencesTest.java │ │ ├── ComposedConstraintsTest.java │ │ ├── ConstraintCompositionTest.java │ │ ├── ConstraintDefinitionsTest.java │ │ ├── ContextConstraintValidatorFactoryTest.java │ │ ├── CustomConstraintValidatorFactoryTest.java │ │ ├── CustomValidatorFactoryTest.java │ │ ├── DefaultMessageInterpolatorTest.java │ │ ├── DelegateExpressionFactory.java │ │ ├── ExceptionsContractTest.java │ │ ├── FooTest.java │ │ ├── Jsr303Test.java │ │ ├── LiskovTest.java │ │ ├── PayloadTest.java │ │ ├── TckReproducerTest.java │ │ ├── ValidationTest.java │ │ ├── ValidationTestBase.java │ │ ├── ValidatorResolutionTest.java │ │ ├── cdi │ │ └── CdiConstraintOnlyOnParentClassTest.java │ │ ├── example │ │ ├── AccessTestBusinessObject.java │ │ ├── AccessTestBusinessObjectSub.java │ │ ├── Address.java │ │ ├── Author.java │ │ ├── Book.java │ │ ├── BusinessAddress.java │ │ ├── CompanyAddress.java │ │ ├── Continent.java │ │ ├── Country.java │ │ ├── Customer.java │ │ ├── Employee.java │ │ ├── Engine.java │ │ ├── First.java │ │ ├── FrenchAddress.java │ │ ├── IllustratedBook.java │ │ ├── Last.java │ │ ├── Library.java │ │ ├── MaxTestEntity.java │ │ ├── NoValidatorTestEntity.java │ │ ├── Person.java │ │ ├── PreferredGuest.java │ │ ├── RecursiveFoo.java │ │ ├── Second.java │ │ ├── SizeTestEntity.java │ │ ├── XmlEntitySampleBean.java │ │ └── ZipCodeCityCarrier.java │ │ ├── extensions │ │ ├── ExampleMethodService.java │ │ └── MethodValidatorImplTest.java │ │ ├── groups │ │ ├── Billable.java │ │ ├── BillableCreditCard.java │ │ ├── BillableUser.java │ │ ├── BuyInOneClick.java │ │ ├── CollectionValidationTest.java │ │ ├── CyclicGroupSequence.java │ │ ├── CyclicGroupSequence1.java │ │ ├── CyclicGroupSequence2.java │ │ ├── DefaultGroupSequenceTest.java │ │ ├── GClass1.java │ │ ├── GClass2.java │ │ ├── GClass3.java │ │ ├── GInterface1.java │ │ ├── GroupSequenceIsolationTest.java │ │ ├── GroupSequenceTest.java │ │ ├── GroupValidationTest.java │ │ ├── GroupsComputerTest.java │ │ ├── implicit │ │ │ ├── Auditable.java │ │ │ ├── ImplicitGroupingTest.java │ │ │ └── Order.java │ │ ├── inheritance │ │ │ ├── BillableUser.java │ │ │ ├── BuyInOneClick.java │ │ │ └── GroupInheritanceTest.java │ │ └── redefining │ │ │ ├── Address.java │ │ │ ├── InvalidRedefinedDefaultGroupAddress.java │ │ │ └── RedefiningDefaultGroupTest.java │ │ ├── issues │ │ ├── BVAL174.java │ │ └── BVAL174Test.java │ │ ├── metadata │ │ └── ContainerElementKeyTest.java │ │ ├── util │ │ ├── LookBehindRegexHolderTest.java │ │ ├── PathImplTest.java │ │ └── TestUtils.java │ │ └── xml │ │ ├── Demo.java │ │ ├── TestConstraintValidatorFactory.java │ │ ├── TestMessageInterpolator.java │ │ └── ValidationParserTest.java │ └── resources │ ├── META-INF │ └── services │ │ └── jakarta.el.ExpressionFactory │ ├── ValidationMessages.properties │ ├── java.policy │ ├── sample-constraints.xml │ ├── sample-validation.xml │ ├── sample-validation11.xml │ ├── sample-validation2.xml │ ├── sample-validation3.xml │ └── sample-validation31.xml ├── bval-perf ├── pom.xml └── src │ └── test │ └── java │ └── org │ └── apache │ └── bval │ └── jsr │ └── Jsr303Benchmark.java ├── bval-tck ├── pom.xml ├── src │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── apache │ │ │ │ └── bval │ │ │ │ └── arquillian │ │ │ │ ├── BValArquillianExtension.java │ │ │ │ ├── EJBEnricher.java │ │ │ │ ├── LogTckFormatter.java │ │ │ │ └── jndi │ │ │ │ └── BValJndiFactory.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── services │ │ │ │ └── org.jboss.arquillian.core.spi.LoadableExtension │ │ │ └── jndi.properties │ └── test │ │ ├── beanvalidation-tck-tests-suite.xml │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── bval │ │ │ └── tck │ │ │ └── TCKSuiteOWBEnhancements.java │ │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── org.jboss.arquillian.core.spi.LoadableExtension │ │ ├── arquillian.xml │ │ └── logging.properties └── work-tests-suite.xml ├── pom.xml └── src └── site ├── resources └── images │ └── bval-bean-small.png └── site.xml /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | # 18 | version: 2 19 | updates: 20 | - package-ecosystem: "maven" 21 | directory: "/" 22 | schedule: 23 | interval: "daily" 24 | - package-ecosystem: "github-actions" 25 | directory: "/" 26 | schedule: 27 | interval: "daily" 28 | -------------------------------------------------------------------------------- /.github/workflows/bval-ci.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one 3 | # or more contributor license agreements. See the NOTICE file 4 | # distributed with this work for additional information 5 | # regarding copyright ownership. The ASF licenses this file 6 | # to you under the Apache License, Version 2.0 (the 7 | # "License"); you may not use this file except in compliance 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | # 18 | 19 | # NOTE https://infra.apache.org/github-actions-secrets.html 20 | 21 | name: BVal CI 22 | on: [push, pull_request, workflow_dispatch] 23 | 24 | permissions: 25 | contents: read 26 | 27 | jobs: 28 | build: 29 | runs-on: ubuntu-latest 30 | 31 | name: Build (Java ${{ matrix.jdk }}) 32 | strategy: 33 | matrix: 34 | jdk: [ '17', '21', '23' ] 35 | 36 | steps: 37 | - uses: actions/checkout@v4 38 | with: 39 | persist-credentials: false 40 | 41 | - name: Set up JDK ${{ matrix.jdk }} 42 | uses: actions/setup-java@v4 43 | with: 44 | distribution: 'temurin' 45 | java-version: ${{ matrix.jdk }} 46 | cache: 'maven' 47 | - name: Build with Maven 48 | run: mvn clean install -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | .settings 4 | .DS_Store 5 | dependency-reduced-pom.xml 6 | target/ 7 | *.iml 8 | *.ipr 9 | *.iws 10 | *.swp 11 | /*/src/main/java/META-INF 12 | .gitignore.swp 13 | docs/reference/src/main/docbook/en-US/version_info.xml 14 | .idea 15 | .forge_settings 16 | .factorypath 17 | atlassian-ide-plugin.xml 18 | .externalToolBuilders 19 | profile.jfr -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | 2 | Apache BVal project 3 | Copyright 2010-2018 The Apache Software Foundation. 4 | 5 | This product includes software developed by 6 | The Apache Software Foundation (http://www.apache.org/). 7 | 8 | 9 | The following copyright notice(s) were affixed to portions of this code 10 | with which this file is now or was at one time distributed. 11 | 12 | This product includes software developed by Agimatec GmbH. 13 | Copyright 2007-2010 Agimatec GmbH. All rights reserved. 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 18 | 19 | # Apache BVal 20 | [![Build Status](https://github.com/apache/bval/workflows/BVal%20CI/badge.svg)](https://github.com/apache/bval/actions/workflows/bval-ci.yml) 21 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 22 | 23 | This is an implementation of the Jakarta Validation (JSRs 303, 349, 380) specification for Jakarta EE and Java SE. 24 | The technical objective is to provide a class level constraint declaration and validation facility for the Java application developer, as well as a constraint 25 | metadata repository and query API. 26 | See: https://beanvalidation.org/ 27 | 28 | ## Branches 29 | 30 | ### Master / 3.1.x 31 | 32 | Jakarta Validation 3.1 implementation 33 | 34 | ### 3.0.x 35 | 36 | Bean Validation 3.0 implementation 37 | 38 | ### 2.x 39 | 40 | Bean Validation 2.x implementation 41 | 42 | ### 1.1.x 43 | 44 | Bean Validation 1.x implementation 45 | 46 | ## Installation 47 | 48 | ```shell 49 | mvn clean install 50 | ``` 51 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | Apache BVal - README.txt 2 | Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 3 | -------------------------------------------------------------------------------- 4 | 5 | About 6 | ===== 7 | This is an implementation of the Java Bean Validation (JSRs 303, 349, 380) 8 | specification for Jakarta EE and Java SE. 9 | The technical objective is to provide a class level constraint declaration and 10 | validation facility for the Java application developer, as well as a constraint 11 | metadata repository and query API. 12 | 13 | 14 | Release Notes 15 | ============= 16 | Please refer to the included CHANGES.txt for a complete list of new features 17 | available and issues resolved in this release. 18 | 19 | 20 | Getting Started 21 | =============== 22 | Please visit the project website for the latest information: 23 | http://bval.apache.org/ 24 | 25 | Along with the developer mailing list archive: 26 | http://mail-archives.apache.org/mod_mbox/bval-dev/ 27 | 28 | 29 | System Requirements 30 | =================== 31 | You need a platform that supports Java SE 8 or later. 32 | Most testing has been done with Java SE 8 on Mac OS X, Windows and Linux. 33 | 34 | 35 | Building 36 | ========================== 37 | To build from source code: 38 | - Sources require Java SE 8 or higher. 39 | - The project is built with Apache Maven (suggested is at least 3.2.1). 40 | You need to download and install Maven from: http://maven.apache.org/ 41 | - Invoke maven in the root directory or a module subdirectory: 42 | mvn install 43 | 44 | Checkout the Building section on the project web site for more details: 45 | http://bval.apache.org/ 46 | 47 | 48 | Support 49 | ======= 50 | Any problems with this release can be reported to the user mailing list or 51 | opened in the Jira issue tracker. 52 | 53 | Mailing list archive: 54 | http://mail-archives.apache.org/mod_mbox/bval-user/ 55 | 56 | User mailing list: 57 | user@bval.apache.org 58 | 59 | User mailing list subscription: 60 | user-subscribe@bval.apache.org 61 | 62 | Jira: 63 | https://issues.apache.org/jira/browse/BVAL/ 64 | 65 | -------------------------------------------------------------------------------- 66 | 67 | -------------------------------------------------------------------------------- /RELEASE-NOTES.adoc: -------------------------------------------------------------------------------- 1 | Apache BVal Release Notes 2 | ========================= 3 | 4 | Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 5 | 6 | 7 | == Introduction 8 | 9 | Apache BVal is an implementation of the JSR-303 and JSR-346 Bean Validation specifications. 10 | 11 | 12 | == Release Notes 13 | 14 | 15 | === BVal-1.1.0 16 | 17 | Bug 18 | 19 | [BVAL-127] - Build failed java 8 20 | [BVAL-128] - Validation of bean that implements Closeable results in an NPE 21 | [BVAL-130] - ConstraintDefaults doesn't close InputStream 22 | 23 | Improvement 24 | 25 | [BVAL-132] - TCK 1.1: BValInterceptor.isGetter is wrong 26 | [BVAL-133] - Updated TCK Test Version for Bean Validation 1.1 27 | 28 | New Feature 29 | 30 | [BVAL-122] - Implement Bean Validation 1.1 31 | 32 | Task 33 | 34 | [BVAL-120] - Add bval-tck11 tck runner for future work on Bean Validation 1.1 35 | [BVAL-131] - Add gitignore 36 | [BVAL-136] - fix artifactId of our bundle module 37 | 38 | Wish 39 | 40 | [BVAL-112] - ability to hide the log message of ConfigurationImpl 41 | 42 | 43 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/checkdigit/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /** 21 | * This package contains Check Digit validation routines. 22 | */ 23 | package org.apache.bval.extras.constraints.checkdigit; 24 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /** 21 | * This package contains Credit Card validation routines. 22 | */ 23 | package org.apache.bval.extras.constraints.creditcard; 24 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/file/Directory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.extras.constraints.file; 20 | 21 | import jakarta.validation.Constraint; 22 | import jakarta.validation.Payload; 23 | import java.lang.annotation.Documented; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 28 | import static java.lang.annotation.ElementType.FIELD; 29 | import static java.lang.annotation.ElementType.PARAMETER; 30 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 31 | 32 | /** 33 | *

34 | * -- 35 | * TODO - This class is NOT part of the bean_validation spec and might disappear 36 | * as soon as a final version of the specification contains a similar functionality. 37 | * -- 38 | *

39 | * Description: annotation to validate a java.io.File is a directory
40 | */ 41 | @Documented 42 | @Constraint(validatedBy = DirectoryValidator.class) 43 | @Target({ FIELD, ANNOTATION_TYPE, PARAMETER }) 44 | @Retention(RUNTIME) 45 | public @interface Directory { 46 | 47 | Class[] groups() default {}; 48 | 49 | String message() default "{org.apache.bval.extras.constraints.file.Directory.message}"; 50 | 51 | Class[] payload() default {}; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/file/DirectoryValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.extras.constraints.file; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import java.io.File; 24 | 25 | /** 26 | * Description:
27 | */ 28 | public class DirectoryValidator implements ConstraintValidator { 29 | 30 | /** 31 | * {@inheritDoc} 32 | */ 33 | @Override 34 | public boolean isValid(File value, ConstraintValidatorContext context) { 35 | return value.isDirectory(); 36 | } 37 | 38 | /** 39 | * {@inheritDoc} 40 | */ 41 | @Override 42 | public void initialize(Directory parameters) { 43 | // do nothing (as long as Directory has no properties) 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/file/NotDirectory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.extras.constraints.file; 20 | 21 | import jakarta.validation.Constraint; 22 | import jakarta.validation.Payload; 23 | import java.lang.annotation.Documented; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 28 | import static java.lang.annotation.ElementType.FIELD; 29 | import static java.lang.annotation.ElementType.PARAMETER; 30 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 31 | 32 | /** 33 | *

34 | * -- 35 | * TODO - This class is NOT part of the bean_validation spec and might disappear 36 | * as soon as a final version of the specification contains a similar functionality. 37 | * -- 38 | *

39 | * Description: annotation to validate a java.io.File is not a directory
40 | */ 41 | @Documented 42 | @Constraint(validatedBy = DirectoryValidator.class) 43 | @Target({ FIELD, ANNOTATION_TYPE, PARAMETER }) 44 | @Retention(RUNTIME) 45 | public @interface NotDirectory { 46 | 47 | Class[] groups() default {}; 48 | 49 | String message() default "{org.apache.bval.extras.constraints.file.NotDirectory.message}"; 50 | 51 | Class[] payload() default {}; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/file/NotDirectoryValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.extras.constraints.file; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import java.io.File; 24 | 25 | /** 26 | * Description:
27 | */ 28 | public class NotDirectoryValidator implements ConstraintValidator { 29 | 30 | /** 31 | * {@inheritDoc} 32 | */ 33 | @Override 34 | public boolean isValid(File value, ConstraintValidatorContext context) { 35 | return value.exists() && !value.isDirectory(); 36 | } 37 | 38 | /** 39 | * {@inheritDoc} 40 | */ 41 | @Override 42 | public void initialize(NotDirectory parameters) { 43 | // do nothing (as long as Directory has no properties) 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/file/Symlink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.extras.constraints.file; 20 | 21 | import jakarta.validation.Constraint; 22 | import jakarta.validation.Payload; 23 | import java.lang.annotation.Documented; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 28 | import static java.lang.annotation.ElementType.FIELD; 29 | import static java.lang.annotation.ElementType.PARAMETER; 30 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 31 | 32 | /** 33 | *

34 | * -- 35 | * TODO - This class is NOT part of the bean_validation spec and might disappear 36 | * as soon as a final version of the specification contains a similar functionality. 37 | * -- 38 | *

39 | * Description: annotation to validate a java.io.File is a symbolic link
40 | */ 41 | @Documented 42 | @Constraint(validatedBy = SymlinkValidator.class) 43 | @Target({ FIELD, ANNOTATION_TYPE, PARAMETER }) 44 | @Retention(RUNTIME) 45 | public @interface Symlink { 46 | 47 | Class[] groups() default {}; 48 | 49 | String message() default "{org.apache.bval.extras.constraints.file.Symlink.message}"; 50 | 51 | Class[] payload() default {}; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/file/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * {@link java.io.File} constraints validators. 20 | */ 21 | package org.apache.bval.extras.constraints.file; 22 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/net/Domain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.extras.constraints.net; 20 | 21 | import jakarta.validation.Constraint; 22 | import jakarta.validation.Payload; 23 | import java.lang.annotation.Documented; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 28 | import static java.lang.annotation.ElementType.FIELD; 29 | import static java.lang.annotation.ElementType.PARAMETER; 30 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 31 | 32 | /** 33 | *

34 | * -- 35 | * TODO - This class is NOT part of the bean_validation spec and might disappear 36 | * as soon as a final version of the specification contains a similar functionality. 37 | * -- 38 | *

39 | * Description: annotation to validate a java.io.File is a directory
40 | */ 41 | @Documented 42 | @Constraint(validatedBy = DomainValidator.class) 43 | @Target({ FIELD, ANNOTATION_TYPE, PARAMETER }) 44 | @Retention(RUNTIME) 45 | public @interface Domain { 46 | 47 | Class[] groups() default {}; 48 | 49 | String message() default "{org.apache.bval.extras.constraints.net.Domain.message}"; 50 | 51 | Class[] payload() default {}; 52 | 53 | boolean allowLocal() default false; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.extras.constraints.net; 20 | 21 | import jakarta.validation.Constraint; 22 | import jakarta.validation.Payload; 23 | import java.lang.annotation.Documented; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 28 | import static java.lang.annotation.ElementType.FIELD; 29 | import static java.lang.annotation.ElementType.PARAMETER; 30 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 31 | 32 | /** 33 | *

34 | * -- 35 | * TODO - This class is NOT part of the bean_validation spec and might disappear 36 | * as soon as a final version of the specification contains a similar functionality. 37 | * -- 38 | *

39 | * Description: annotation to validate a java.io.File is a directory
40 | */ 41 | @Documented 42 | @Constraint(validatedBy = InetAddressValidator.class) 43 | @Target({ FIELD, ANNOTATION_TYPE, PARAMETER }) 44 | @Retention(RUNTIME) 45 | public @interface InetAddress { 46 | 47 | Class[] groups() default {}; 48 | 49 | String message() default "{org.apache.bval.extras.constraints.net.InetAddress.message}"; 50 | 51 | Class[] payload() default {}; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/net/InetAddressValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.extras.constraints.net; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import java.util.regex.Pattern; 24 | 25 | /** 26 | *

InetAddress validation and conversion routines (java.net.InetAddress).

27 | * 28 | *

This class provides methods to validate a candidate IP address. 29 | */ 30 | public class InetAddressValidator implements ConstraintValidator { 31 | 32 | private static final Pattern IPV4_PATTERN = 33 | Pattern.compile("^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." 34 | + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"); 35 | 36 | /** 37 | * {@inheritDoc} 38 | */ 39 | @Override 40 | public boolean isValid(CharSequence value, ConstraintValidatorContext context) { 41 | if (!IPV4_PATTERN.matcher(value).matches()) { 42 | return false; 43 | } 44 | 45 | return true; 46 | } 47 | 48 | /** 49 | * {@inheritDoc} 50 | */ 51 | @Override 52 | public void initialize(InetAddress parameters) { 53 | // do nothing (as long as InetAddress has no properties) 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/net/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * net constraints validators. 20 | */ 21 | package org.apache.bval.extras.constraints.net; 22 | -------------------------------------------------------------------------------- /bval-extras/src/main/java/org/apache/bval/extras/constraints/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Contains constraints that are NOT part of the Bean Validation specification 20 | * and might disappear as soon as a final version of the specification contains 21 | * similar functionalities. 22 | */ 23 | package org.apache.bval.extras.constraints; 24 | -------------------------------------------------------------------------------- /bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ABANumberValidatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.extras.constraints.checkdigit; 18 | 19 | import jakarta.validation.ConstraintValidator; 20 | import java.lang.annotation.Annotation; 21 | 22 | /** 23 | * ABA Number Validator Test. 24 | */ 25 | public class ABANumberValidatorTest extends AbstractCheckDigitTest { 26 | 27 | @Override 28 | protected ConstraintValidator getConstraint() { 29 | return new ABANumberValidator(); 30 | } 31 | 32 | @Override 33 | protected String[] getValid() { 34 | return new String[] { "123456780", "123123123", "011000015", "111000038", "231381116", "121181976" }; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/CUSIPValidatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.extras.constraints.checkdigit; 18 | 19 | import jakarta.validation.ConstraintValidator; 20 | import java.lang.annotation.Annotation; 21 | 22 | /** 23 | * CUSIP Check Digit Test. 24 | */ 25 | public class CUSIPValidatorTest extends AbstractCheckDigitTest { 26 | 27 | @Override 28 | protected ConstraintValidator getConstraint() { 29 | return new CUSIPValidator(); 30 | } 31 | 32 | @Override 33 | protected String[] getValid() { 34 | return new String[] { "037833100", "931142103", "837649128", "392690QT3", "594918104", "86770G101", "Y8295N109", 35 | "G8572F100" }; 36 | } 37 | 38 | @Override 39 | protected String[] getInvalid() { 40 | return new String[] { "0378#3100" }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/EAN13CheckDigitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.extras.constraints.checkdigit; 18 | 19 | import jakarta.validation.ConstraintValidator; 20 | import java.lang.annotation.Annotation; 21 | 22 | /** 23 | * EAN-13 Check Digit Test. 24 | */ 25 | public class EAN13CheckDigitTest extends AbstractCheckDigitTest { 26 | 27 | @Override 28 | protected ConstraintValidator getConstraint() { 29 | return new EAN13Validator(); 30 | } 31 | 32 | @Override 33 | protected String[] getValid() { 34 | return new String[] { 35 | "9780072129519", 36 | "9780764558313", 37 | "4025515373438", 38 | "0095673400332" 39 | }; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/ISBN10CheckDigitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.extras.constraints.checkdigit; 18 | 19 | import jakarta.validation.ConstraintValidator; 20 | import java.lang.annotation.Annotation; 21 | 22 | /** 23 | * ISBN-10 Check Digit Test. 24 | */ 25 | public class ISBN10CheckDigitTest extends AbstractCheckDigitTest { 26 | 27 | @Override 28 | protected ConstraintValidator getConstraint() { 29 | return new ISBN10Validator(); 30 | } 31 | 32 | @Override 33 | protected String[] getValid() { 34 | return new String[] { 35 | "1930110995", 36 | "020163385X", 37 | "1932394354", 38 | "1590596277" 39 | }; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/LuhnCheckDigitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.extras.constraints.checkdigit; 18 | 19 | import jakarta.validation.ConstraintValidator; 20 | import java.lang.annotation.Annotation; 21 | 22 | /** 23 | * Luhn Check Digit Test. 24 | */ 25 | public class LuhnCheckDigitTest extends AbstractCheckDigitTest { 26 | 27 | private static final String VALID_VISA = "4417123456789113"; 28 | 29 | private static final String VALID_SHORT_VISA = "4222222222222"; 30 | 31 | private static final String VALID_AMEX = "378282246310005"; 32 | 33 | private static final String VALID_MASTERCARD = "5105105105105100"; 34 | 35 | private static final String VALID_DISCOVER = "6011000990139424"; 36 | 37 | private static final String VALID_DINERS = "30569309025904"; 38 | 39 | @Override 40 | protected ConstraintValidator getConstraint() { 41 | return new LuhnValidator(); 42 | } 43 | 44 | @Override 45 | protected String[] getValid() { 46 | return new String[] { 47 | VALID_VISA, 48 | VALID_SHORT_VISA, 49 | VALID_AMEX, 50 | VALID_MASTERCARD, 51 | VALID_DISCOVER, 52 | VALID_DINERS 53 | }; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/SedolCheckDigitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.extras.constraints.checkdigit; 18 | 19 | import jakarta.validation.ConstraintValidator; 20 | import java.lang.annotation.Annotation; 21 | 22 | /** 23 | * Sedol Check Digit Test. 24 | */ 25 | public class SedolCheckDigitTest extends AbstractCheckDigitTest { 26 | 27 | @Override 28 | protected ConstraintValidator getConstraint() { 29 | return new SedolValidator(); 30 | } 31 | 32 | @Override 33 | protected String[] getValid() { 34 | return new String[] { 35 | "0263494", 36 | "0870612", 37 | "B06LQ97", 38 | "3437575", 39 | "B07LF55", 40 | }; 41 | } 42 | 43 | @Override 44 | protected String[] getInvalid() { 45 | return new String[] {"123#567"}; 46 | } 47 | 48 | @Override 49 | protected String getZeroSum() { 50 | return "0000000"; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /bval-extras/src/test/java/org/apache/bval/extras/constraints/checkdigit/VerhoeffCheckDigitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.extras.constraints.checkdigit; 18 | 19 | import org.junit.Ignore; 20 | import org.junit.Test; 21 | 22 | import jakarta.validation.ConstraintValidator; 23 | import java.lang.annotation.Annotation; 24 | 25 | /** 26 | * Verhoeff Check Digit Test. 27 | */ 28 | public class VerhoeffCheckDigitTest extends AbstractCheckDigitTest { 29 | 30 | @Override 31 | protected ConstraintValidator getConstraint() { 32 | return new VerhoeffValidator(); 33 | } 34 | 35 | @Override 36 | protected String[] getValid() { 37 | return new String[] { 38 | "15", 39 | "1428570", 40 | "12345678902" 41 | }; 42 | } 43 | 44 | /** 45 | * Test zero sum 46 | */ 47 | @Override 48 | @Test 49 | @Ignore 50 | public void testZeroSum() { 51 | // ignore, don't run this test 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/cdi/AnyLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.cdi; 20 | 21 | import jakarta.enterprise.inject.Any; 22 | 23 | public class AnyLiteral extends EmptyAnnotationLiteral implements Any { 24 | private static final long serialVersionUID = 1L; 25 | 26 | /** 27 | * Statically available instance. 28 | */ 29 | public static final AnyLiteral INSTANCE = new AnyLiteral(); 30 | 31 | @Override 32 | public String toString() { 33 | return String.format("@%s()", Any.class.getName()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/cdi/BValBinding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.cdi; 20 | 21 | import jakarta.interceptor.InterceptorBinding; 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | /** 28 | * Custom {@link InterceptorBinding} to invoke executable validations on CDI beans. 29 | */ 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target({ ElementType.TYPE }) 32 | @InterceptorBinding 33 | public @interface BValBinding { 34 | } 35 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/cdi/DefaultLiteral.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.cdi; 20 | 21 | import jakarta.enterprise.inject.Default; 22 | 23 | public class DefaultLiteral extends EmptyAnnotationLiteral implements Default { 24 | private static final long serialVersionUID = 1L; 25 | 26 | public static final DefaultLiteral INSTANCE = new DefaultLiteral(); 27 | 28 | @Override 29 | public String toString() { 30 | return String.format("@%s()", Default.class.getName()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import jakarta.validation.constraints.AssertFalse; 24 | 25 | /** 26 | * Description: assert that value is false
27 | */ 28 | public class AssertFalseValidator implements ConstraintValidator { 29 | 30 | @Override 31 | public boolean isValid(Boolean value, ConstraintValidatorContext context) { 32 | return !Boolean.TRUE.equals(value); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import jakarta.validation.constraints.AssertTrue; 24 | 25 | /** 26 | * Description: assert that value is true
27 | */ 28 | public class AssertTrueValidator implements ConstraintValidator { 29 | 30 | @Override 31 | public boolean isValid(Boolean value, ConstraintValidatorContext context) { 32 | return !Boolean.FALSE.equals(value); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/EmailValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidatorContext; 22 | import jakarta.validation.constraints.Pattern.Flag; 23 | 24 | import org.apache.bval.routines.EMailValidationUtils; 25 | 26 | /** 27 | * Description:
28 | */ 29 | public class EmailValidator extends AbstractPatternValidator { 30 | 31 | public EmailValidator() { 32 | super(email -> new PatternDescriptor() { 33 | 34 | @Override 35 | public String regexp() { 36 | return email.regexp(); 37 | } 38 | 39 | @Override 40 | public Flag[] flags() { 41 | return email.flags(); 42 | } 43 | }); 44 | } 45 | 46 | @Override 47 | public boolean isValid(CharSequence value, ConstraintValidatorContext context) { 48 | return EMailValidationUtils.isValid(value) && super.isValid(value, context); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import jakarta.validation.constraints.Max; 24 | import java.math.BigDecimal; 25 | import java.math.BigInteger; 26 | 27 | /** 28 | * Check that the number being validated is less than or equal to the maximum 29 | * value specified. 30 | */ 31 | public class MaxValidatorForNumber implements ConstraintValidator { 32 | 33 | private long max; 34 | 35 | @Override 36 | public void initialize(Max annotation) { 37 | this.max = annotation.value(); 38 | } 39 | 40 | @Override 41 | public boolean isValid(Number value, ConstraintValidatorContext context) { 42 | if (value == null) { 43 | return true; 44 | } 45 | if (value instanceof BigDecimal) { 46 | return ((BigDecimal) value).compareTo(BigDecimal.valueOf(max)) < 1; 47 | } 48 | if (value instanceof BigInteger) { 49 | return ((BigInteger) value).compareTo(BigInteger.valueOf(max)) < 1; 50 | } 51 | return value.longValue() <= max; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import jakarta.validation.constraints.Max; 24 | import java.math.BigDecimal; 25 | 26 | /** 27 | * Check that the String being validated represents a number, and has a value 28 | * less than or equal to the maximum value specified. 29 | */ 30 | public class MaxValidatorForString implements ConstraintValidator { 31 | 32 | private long max; 33 | 34 | @Override 35 | public void initialize(Max annotation) { 36 | this.max = annotation.value(); 37 | } 38 | 39 | @Override 40 | public boolean isValid(String value, ConstraintValidatorContext context) { 41 | if (value == null) { 42 | return true; 43 | } 44 | try { 45 | return new BigDecimal(value).compareTo(BigDecimal.valueOf(max)) < 1; 46 | } catch (NumberFormatException nfe) { 47 | return false; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/MinValidatorForNumber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import jakarta.validation.constraints.Min; 24 | import java.math.BigDecimal; 25 | import java.math.BigInteger; 26 | 27 | /** 28 | * Description: validate that number-value of passed object is >= min-value
29 | */ 30 | public class MinValidatorForNumber implements ConstraintValidator { 31 | 32 | private long minValue; 33 | 34 | @Override 35 | public void initialize(Min annotation) { 36 | this.minValue = annotation.value(); 37 | } 38 | 39 | @Override 40 | public boolean isValid(Number value, ConstraintValidatorContext context) { 41 | if (value == null) { 42 | return true; 43 | } 44 | if (value instanceof BigDecimal) { 45 | return ((BigDecimal) value).compareTo(BigDecimal.valueOf(minValue)) >= 0; 46 | } 47 | if (value instanceof BigInteger) { 48 | return ((BigInteger) value).compareTo(BigInteger.valueOf(minValue)) >= 0; 49 | } 50 | return value.longValue() >= minValue; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/MinValidatorForString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import jakarta.validation.constraints.Min; 24 | import java.math.BigDecimal; 25 | 26 | /** 27 | * Check that the String being validated represents a number, and has a value 28 | * more than or equal to the minimum value specified. 29 | */ 30 | public class MinValidatorForString implements ConstraintValidator { 31 | 32 | private long minValue; 33 | 34 | @Override 35 | public void initialize(Min annotation) { 36 | this.minValue = annotation.value(); 37 | } 38 | 39 | @Override 40 | public boolean isValid(String value, ConstraintValidatorContext context) { 41 | if (value == null) { 42 | return true; 43 | } 44 | try { 45 | return new BigDecimal(value).compareTo(BigDecimal.valueOf(minValue)) >= 0; 46 | } catch (NumberFormatException nfe) { 47 | return false; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/NotBlankValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import jakarta.validation.constraints.NotBlank; 24 | 25 | /** 26 | * Validate {@link NotBlank} for {@link CharSequence}. 27 | */ 28 | public class NotBlankValidator implements ConstraintValidator { 29 | 30 | @Override 31 | public boolean isValid(CharSequence value, ConstraintValidatorContext context) { 32 | return value != null && value.length() > 0 && !value.chars().allMatch(Character::isWhitespace); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/NotEmptyValidatorForCharSequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | 24 | /** 25 | * Description:
26 | */ 27 | public class NotEmptyValidatorForCharSequence 28 | implements ConstraintValidator { 29 | 30 | @Override 31 | public boolean isValid(CharSequence value, ConstraintValidatorContext context) { 32 | return value != null && value.length() > 0; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/NotEmptyValidatorForCollection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import java.util.Collection; 24 | 25 | /** 26 | * Description:
27 | */ 28 | public class NotEmptyValidatorForCollection 29 | implements ConstraintValidator> { 30 | 31 | @Override 32 | public boolean isValid(Collection value, ConstraintValidatorContext context) { 33 | return !(value == null || value.isEmpty()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/NotEmptyValidatorForMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import java.util.Map; 24 | 25 | /** 26 | * Description:
27 | */ 28 | public class NotEmptyValidatorForMap implements ConstraintValidator> { 29 | 30 | @Override 31 | public boolean isValid(Map value, ConstraintValidatorContext context) { 32 | return !(value == null || value.isEmpty()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/NotNullValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import jakarta.validation.constraints.NotNull; 24 | 25 | /** valid when object is NOT null */ 26 | public class NotNullValidator implements ConstraintValidator { 27 | 28 | @Override 29 | public boolean isValid(Object value, ConstraintValidatorContext context) { 30 | return value != null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/NullValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | import jakarta.validation.constraints.Null; 24 | 25 | /** 26 | * Description: valid when object is null
27 | */ 28 | public class NullValidator implements ConstraintValidator { 29 | 30 | @Override 31 | public boolean isValid(Object object, ConstraintValidatorContext context) { 32 | return object == null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/constraints/PatternValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.constraints.Pattern; 22 | import jakarta.validation.constraints.Pattern.Flag; 23 | 24 | /** 25 | * validator using a regular expression, based on the jsr Pattern constraint annotation. 26 | */ 27 | public class PatternValidator extends AbstractPatternValidator { 28 | public PatternValidator() { 29 | super(p -> new PatternDescriptor() { 30 | 31 | @Override 32 | public String regexp() { 33 | return p.regexp(); 34 | } 35 | 36 | @Override 37 | public Flag[] flags() { 38 | return p.flags(); 39 | } 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/el/MessageEvaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with this 4 | * work for additional information regarding copyright ownership. The ASF 5 | * licenses this file to you under the Apache License, Version 2.0 (the 6 | * "License"); you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package org.apache.bval.el; 18 | 19 | import java.util.Map; 20 | 21 | // just here to ensure we can use Expression Language if at classpath 22 | // but not fail if not here (as before) 23 | public interface MessageEvaluator { 24 | String interpolate(String message, Map annotationParameters, Object validatedValue); 25 | } 26 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/ApacheMessageContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr; 20 | 21 | import jakarta.validation.MessageInterpolator; 22 | import jakarta.validation.MessageInterpolator.Context; 23 | 24 | /** 25 | * Vendor-specific {@link MessageInterpolator.Context} interface extension to 26 | * provide access to validator configuration properties. 27 | */ 28 | public interface ApacheMessageContext extends Context { 29 | 30 | /** 31 | * Get the configuration property value specified by {@code propertyKey}, if available. 32 | * @param propertyKey 33 | * @return {@link String} or {@code null} 34 | */ 35 | String getConfigurationProperty(String propertyKey); 36 | } 37 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/descriptor/ConstructorD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.descriptor; 20 | 21 | import java.lang.reflect.Constructor; 22 | 23 | import jakarta.validation.metadata.ConstructorDescriptor; 24 | 25 | public class ConstructorD extends ExecutableD, MetadataReader.ForConstructor, ConstructorD> 26 | implements ConstructorDescriptor { 27 | 28 | ConstructorD(MetadataReader.ForConstructor reader, BeanD parent) { 29 | super(reader, parent); 30 | } 31 | 32 | @Override 33 | public Class getElementClass() { 34 | return getParent().getElementClass(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/descriptor/ContainerElementTypeD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.descriptor; 20 | 21 | import java.lang.reflect.AnnotatedType; 22 | 23 | import jakarta.validation.metadata.ContainerElementTypeDescriptor; 24 | 25 | import org.apache.bval.jsr.metadata.ContainerElementKey; 26 | import org.apache.bval.util.Validate; 27 | 28 | public class ContainerElementTypeD extends CascadableContainerD, AnnotatedType> 29 | implements ContainerElementTypeDescriptor { 30 | 31 | private final ContainerElementKey key; 32 | 33 | ContainerElementTypeD(ContainerElementKey key, MetadataReader.ForContainer reader, 34 | CascadableContainerD parent) { 35 | super(reader, parent); 36 | this.key = Validate.notNull(key, "key"); 37 | } 38 | 39 | @Override 40 | public Class getContainerClass() { 41 | return key.getContainerClass(); 42 | } 43 | 44 | @Override 45 | public Integer getTypeArgumentIndex() { 46 | return key.getTypeArgumentIndex(); 47 | } 48 | 49 | public ContainerElementKey getKey() { 50 | return key; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/descriptor/CrossParameterD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.jsr.descriptor; 18 | 19 | import java.lang.reflect.Executable; 20 | 21 | import jakarta.validation.metadata.CrossParameterDescriptor; 22 | 23 | public class CrossParameterD

, E extends Executable> 24 | extends ElementD.NonRoot> implements CrossParameterDescriptor { 25 | 26 | protected CrossParameterD(MetadataReader.ForElement reader, P parent) { 27 | super(reader, parent); 28 | } 29 | 30 | @Override 31 | public Class getElementClass() { 32 | return Object[].class; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/descriptor/MethodD.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.descriptor; 20 | 21 | import java.lang.reflect.Method; 22 | 23 | import jakarta.validation.metadata.MethodDescriptor; 24 | import jakarta.validation.metadata.MethodType; 25 | 26 | import org.apache.bval.jsr.util.Methods; 27 | 28 | class MethodD extends ExecutableD implements MethodDescriptor { 29 | private final MethodType methodType; 30 | 31 | MethodD(MetadataReader.ForMethod reader, BeanD parent) { 32 | super(reader, parent); 33 | methodType = Methods.isGetter(reader.meta.getHost()) ? MethodType.GETTER : MethodType.NON_GETTER; 34 | } 35 | 36 | @Override 37 | public Class getElementClass() { 38 | return getTarget().getReturnType(); 39 | } 40 | 41 | MethodType getMethodType() { 42 | return methodType; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/descriptor/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | /** 18 | * This package houses the implementations and related classes for BV element descriptors, using the {@code D} suffix to 19 | * succinctly denote implementations of {@code *Descriptor}. 20 | */ 21 | package org.apache.bval.jsr.descriptor; -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/metadata/AnnotationBehavior.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.jsr.metadata; 18 | 19 | import org.apache.bval.jsr.metadata.MetadataBuilder; 20 | 21 | /** 22 | * Models the behavior of a {@link MetadataBuilder} with regard to bean validation annotations. 23 | * 24 | * @see DualBuilder 25 | */ 26 | public enum AnnotationBehavior implements AnnotationBehaviorMergeStrategy { 27 | //@formatter:off 28 | INCLUDE, EXCLUDE, ABSTAIN; 29 | //@formatter:on 30 | 31 | @Override 32 | public AnnotationBehavior apply(Iterable t) { 33 | return this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/metadata/AnnotationDeclaredValidatorMappingProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.jsr.metadata; 18 | 19 | import java.lang.annotation.Annotation; 20 | import java.util.Arrays; 21 | import java.util.List; 22 | 23 | import jakarta.validation.Constraint; 24 | import jakarta.validation.ConstraintValidator; 25 | 26 | import org.apache.bval.util.Validate; 27 | 28 | public class AnnotationDeclaredValidatorMappingProvider extends ValidatorMappingProvider { 29 | public static final AnnotationDeclaredValidatorMappingProvider INSTANCE = 30 | new AnnotationDeclaredValidatorMappingProvider(); 31 | 32 | @Override 33 | protected ValidatorMapping doGetValidatorMapping(Class constraintType) { 34 | Validate.notNull(constraintType); 35 | Validate.isTrue(constraintType.isAnnotationPresent(Constraint.class), 36 | "%s does not represent a validation constraint", constraintType); 37 | @SuppressWarnings({ "unchecked", "rawtypes" }) 38 | final List>> validatorTypes = 39 | (List) Arrays.asList(constraintType.getAnnotation(Constraint.class).validatedBy()); 40 | return new ValidatorMapping<>("@Constraint.validatedBy()", validatorTypes); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/metadata/CompositeValidatorMappingProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.jsr.metadata; 18 | 19 | import java.lang.annotation.Annotation; 20 | import java.util.List; 21 | import java.util.Objects; 22 | import java.util.stream.Collectors; 23 | 24 | import org.apache.bval.util.Validate; 25 | 26 | public class CompositeValidatorMappingProvider extends ValidatorMappingProvider { 27 | 28 | private final List delegates; 29 | 30 | public CompositeValidatorMappingProvider(List delegates) { 31 | super(); 32 | this.delegates = Validate.notNull(delegates, "delegates"); 33 | Validate.isTrue(!delegates.isEmpty(), "no delegates specified"); 34 | Validate.isTrue(delegates.stream().noneMatch(Objects::isNull), "One or more supplied delegates was null"); 35 | } 36 | 37 | @Override 38 | protected ValidatorMapping doGetValidatorMapping(Class constraintType) { 39 | return ValidatorMapping.merge(delegates.stream().map(d -> d.doGetValidatorMapping(constraintType)) 40 | .filter(Objects::nonNull).collect(Collectors.toList()), AnnotationBehaviorMergeStrategy.consensus()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/metadata/HasAnnotationBehavior.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.jsr.metadata; 18 | 19 | public interface HasAnnotationBehavior { 20 | 21 | default AnnotationBehavior getAnnotationBehavior() { 22 | return AnnotationBehavior.ABSTAIN; 23 | } 24 | } -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/metadata/MetadataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.jsr.metadata; 18 | 19 | import java.util.function.BiConsumer; 20 | import java.util.function.Consumer; 21 | 22 | import jakarta.validation.ConstraintValidator; 23 | import jakarta.validation.spi.ConfigurationState; 24 | 25 | import org.apache.bval.jsr.ApacheValidatorFactory; 26 | 27 | /** 28 | * Service interface for user metadata customizations. 29 | */ 30 | public interface MetadataSource { 31 | /** 32 | * Initialize the {@link MetadataSource}. 33 | * @param validatorFactory 34 | */ 35 | default void initialize(ApacheValidatorFactory validatorFactory) { 36 | } 37 | 38 | /** 39 | * Add {@link ConstraintValidator} mappings and/or metadata builders. 40 | * 41 | * @param configurationState 42 | * may be read for environmental cues 43 | * @param addMappingProvider 44 | * @param addBuilder 45 | */ 46 | void process(ConfigurationState configurationState, Consumer addMappingProvider, 47 | BiConsumer, MetadataBuilder.ForBean> addBuilder); 48 | } 49 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/parameter/DefaultParameterNameProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.parameter; 20 | 21 | import java.lang.reflect.Constructor; 22 | import java.lang.reflect.Executable; 23 | import java.lang.reflect.Method; 24 | import java.lang.reflect.Parameter; 25 | import java.util.List; 26 | import java.util.stream.Collectors; 27 | import java.util.stream.Stream; 28 | 29 | import jakarta.validation.ParameterNameProvider; 30 | 31 | public class DefaultParameterNameProvider implements ParameterNameProvider { 32 | 33 | private static List parameterNames(Executable exe) { 34 | return Stream.of(exe.getParameters()).map(Parameter::getName).collect(Collectors.toList()); 35 | } 36 | 37 | @Override 38 | public List getParameterNames(Constructor constructor) { 39 | return parameterNames(constructor); 40 | } 41 | 42 | @Override 43 | public List getParameterNames(Method method) { 44 | return parameterNames(method); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/resolver/CachingRelevant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.resolver; 20 | 21 | import jakarta.validation.TraversableResolver; 22 | 23 | /** 24 | * Description: indicator interface to let the implementation choose 25 | * whether results of traversable resolver should be cached.
26 | */ 27 | public interface CachingRelevant { 28 | /** 29 | * Learn whether the results of the {@link TraversableResolver} should be cached. 30 | * @return boolean 31 | */ 32 | boolean needsCaching(); 33 | } 34 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/resolver/JPATraversableResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with this 4 | * work for additional information regarding copyright ownership. The ASF 5 | * licenses this file to you under the Apache License, Version 2.0 (the 6 | * "License"); you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 | * License for the specific language governing permissions and limitations under 15 | * the License. 16 | */ 17 | package org.apache.bval.jsr.resolver; 18 | 19 | import jakarta.persistence.Persistence; 20 | import jakarta.validation.Path; 21 | import jakarta.validation.TraversableResolver; 22 | import java.lang.annotation.ElementType; 23 | 24 | /** @see jakarta.validation.TraversableResolver */ 25 | public class JPATraversableResolver implements TraversableResolver, CachingRelevant { 26 | 27 | /** 28 | * {@inheritDoc} 29 | */ 30 | @Override 31 | public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class rootBeanType, 32 | Path pathToTraversableObject, ElementType elementType) { 33 | return traversableObject == null 34 | || Persistence.getPersistenceUtil().isLoaded(traversableObject, traversableProperty.getName()); 35 | } 36 | 37 | /** 38 | * {@inheritDoc} 39 | */ 40 | @Override 41 | public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class rootBeanType, 42 | Path pathToTraversableObject, ElementType elementType) { 43 | return true; 44 | } 45 | 46 | /** 47 | * {@inheritDoc} 48 | */ 49 | @Override 50 | public boolean needsCaching() { 51 | return true; // yes 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/resolver/SimpleTraversableResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.resolver; 20 | 21 | import jakarta.validation.Path; 22 | import jakarta.validation.TraversableResolver; 23 | import java.lang.annotation.ElementType; 24 | 25 | /** 26 | * Description: traversable resolver that does always resolve.
27 | */ 28 | public class SimpleTraversableResolver implements TraversableResolver, CachingRelevant { 29 | /** 30 | * {@inheritDoc} 31 | * @return true 32 | */ 33 | @Override 34 | public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class rootBeanType, 35 | Path pathToTraversableObject, java.lang.annotation.ElementType elementType) { 36 | return true; 37 | } 38 | 39 | /** 40 | * {@inheritDoc} 41 | * @return true 42 | */ 43 | @Override 44 | public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class rootBeanType, 45 | Path pathToTraversableObject, ElementType elementType) { 46 | return true; 47 | } 48 | 49 | /** 50 | * {@inheritDoc} 51 | * @return false 52 | */ 53 | @Override 54 | public boolean needsCaching() { 55 | return false; // no 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/util/IOs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.util; 20 | 21 | import java.io.ByteArrayInputStream; 22 | import java.io.ByteArrayOutputStream; 23 | import java.io.Closeable; 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | 27 | public class IOs { 28 | private IOs() { 29 | // no-op 30 | } 31 | 32 | public static InputStream convertToMarkableInputStream(final InputStream stream) { 33 | if (stream == null) { 34 | return null; 35 | } 36 | try (InputStream in = stream) { 37 | final ByteArrayOutputStream baos = new ByteArrayOutputStream(); 38 | final byte[] buffer = new byte[1024]; 39 | int length; 40 | while ((length = in.read(buffer)) != -1) { 41 | baos.write(buffer, 0, length); 42 | } 43 | return new ByteArrayInputStream(baos.toByteArray()); 44 | } catch (final IOException e) { 45 | throw new RuntimeException(e); 46 | } 47 | } 48 | 49 | //TODO see if needed 50 | public static void closeQuietly(Closeable closeable) { 51 | if (closeable != null) { 52 | try { 53 | closeable.close(); 54 | } catch (IOException e) { 55 | // do nothing 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/valueextraction/IterableElementExtractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.valueextraction; 20 | 21 | import jakarta.validation.valueextraction.ExtractedValue; 22 | import jakarta.validation.valueextraction.ValueExtractor; 23 | 24 | public class IterableElementExtractor implements ValueExtractor> { 25 | 26 | @Override 27 | public void extractValues(Iterable originalValue, ValueExtractor.ValueReceiver receiver) { 28 | originalValue.forEach(v -> receiver.iterableValue("", v)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/valueextraction/ListElementExtractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.valueextraction; 20 | 21 | import java.util.List; 22 | 23 | import jakarta.validation.valueextraction.ExtractedValue; 24 | import jakarta.validation.valueextraction.ValueExtractor; 25 | 26 | public class ListElementExtractor implements ValueExtractor> { 27 | 28 | @Override 29 | public void extractValues(List originalValue, ValueExtractor.ValueReceiver receiver) { 30 | for (int i = 0, sz = originalValue.size(); i < sz; i++) { 31 | receiver.indexedValue("", i, originalValue.get(i)); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/jsr/valueextraction/MapExtractor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.valueextraction; 20 | 21 | import java.util.Map; 22 | 23 | import jakarta.validation.valueextraction.ExtractedValue; 24 | import jakarta.validation.valueextraction.ValueExtractor; 25 | 26 | public abstract class MapExtractor { 27 | public static class ForKey implements ValueExtractor> { 28 | 29 | @Override 30 | public void extractValues(Map originalValue, ValueExtractor.ValueReceiver receiver) { 31 | originalValue.keySet().forEach(k -> receiver.keyedValue("", k, k)); 32 | } 33 | } 34 | 35 | public static class ForValue implements ValueExtractor> { 36 | 37 | @Override 38 | public void extractValues(Map originalValue, ValueExtractor.ValueReceiver receiver) { 39 | originalValue.entrySet().forEach(e -> receiver.keyedValue("", e.getKey(), e.getValue())); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/util/CloseableAble.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.util; 20 | 21 | import java.io.Closeable; 22 | 23 | @FunctionalInterface 24 | public interface CloseableAble { 25 | 26 | Closeable getCloseable(); 27 | } 28 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/util/Comparators.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.util; 18 | 19 | import java.util.Comparator; 20 | import java.util.Iterator; 21 | 22 | /** 23 | * {@link Comparator} related utilities. 24 | */ 25 | public class Comparators { 26 | 27 | /** 28 | * Get a {@link Comparator} capable of comparing {@link Iterable}s. 29 | * 30 | * @param each 31 | * @return {@link Comparator} 32 | */ 33 | public static > Comparator comparingIterables(Comparator each) { 34 | return (quid, quo) -> { 35 | final Iterator quids = quid.iterator(); 36 | final Iterator quos = quo.iterator(); 37 | 38 | while (quids.hasNext()) { 39 | if (quos.hasNext()) { 40 | final int rz = each.compare(quids.next(), quos.next()); 41 | if (rz != 0) { 42 | return rz; 43 | } 44 | continue; 45 | } 46 | return 1; 47 | } 48 | return quos.hasNext() ? -1 : 0; 49 | }; 50 | } 51 | 52 | private Comparators() { 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/util/LazyInt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.util; 18 | 19 | import java.util.OptionalInt; 20 | import java.util.function.IntSupplier; 21 | 22 | /** 23 | * @since 2.0 24 | */ 25 | public class LazyInt implements IntSupplier { 26 | private int value; 27 | private volatile IntSupplier init; 28 | 29 | public LazyInt(IntSupplier init) { 30 | this.init = Validate.notNull(init); 31 | } 32 | 33 | @Override 34 | public int getAsInt() { 35 | if (init != null) { 36 | synchronized (this) { 37 | if (init != null) { 38 | value = init.getAsInt(); 39 | init = null; 40 | } 41 | } 42 | } 43 | return value; 44 | } 45 | 46 | public synchronized OptionalInt optional() { 47 | return init == null ? OptionalInt.of(value) : OptionalInt.empty(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /bval-jsr/src/main/java/org/apache/bval/util/ObjectWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.util; 20 | 21 | import java.util.Optional; 22 | import java.util.function.Consumer; 23 | import java.util.function.Supplier; 24 | 25 | public class ObjectWrapper implements Consumer, Supplier { 26 | private T value; 27 | 28 | public ObjectWrapper() { 29 | this(null); 30 | } 31 | 32 | public ObjectWrapper(T value) { 33 | super(); 34 | this.value = value; 35 | } 36 | 37 | @Override 38 | public void accept(T value) { 39 | this.value = value; 40 | } 41 | 42 | @Override 43 | public T get() { 44 | return value; 45 | } 46 | 47 | public Optional optional() { 48 | return Optional.ofNullable(value); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /bval-jsr/src/main/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | org.apache.bval.cdi.BValExtension -------------------------------------------------------------------------------- /bval-jsr/src/main/resources/META-INF/services/jakarta.validation.spi.ValidationProvider: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | org.apache.bval.jsr.ApacheValidationProvider 18 | -------------------------------------------------------------------------------- /bval-jsr/src/main/resources/META-INF/services/org.apache.bval.jsr.metadata.MetadataSource: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | org.apache.bval.jsr.xml.ValidationMappingParser -------------------------------------------------------------------------------- /bval-jsr/src/main/resources/org/apache/bval/jsr/ValidationMessages_en.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | # intentionally empty, because english messages are located in the default bundle. 19 | # this file ensures, that a lookup with an english locale uses the default bundle and not the 20 | # bundle of the default locale, which is platform specific -------------------------------------------------------------------------------- /bval-jsr/src/main/resources/org/apache/bval/jsr/valueextraction/DefaultExtractors.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | jakarta.validation.valueextraction.ValueExtractor=\ 19 | org.apache.bval.jsr.valueextraction.IterableElementExtractor,\ 20 | org.apache.bval.jsr.valueextraction.ListElementExtractor 21 | 22 | jakarta.validation.valueextraction.ValueExtractor.container=\ 23 | org.apache.bval.jsr.valueextraction.MapExtractor,\ 24 | org.apache.bval.jsr.valueextraction.OptionalExtractor,\ 25 | org.apache.bval.jsr.valueextraction.FxExtractor 26 | -------------------------------------------------------------------------------- /bval-jsr/src/main/xjb/binding-customization.xjb: -------------------------------------------------------------------------------- 1 | 2 | 20 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/constraints/AssertFalseValidatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import static org.junit.Assert.assertFalse; 22 | import static org.junit.Assert.assertTrue; 23 | 24 | import org.junit.Test; 25 | 26 | /** 27 | * Checks correct behaviour of {@link AssertFalseValidator}. 28 | *

29 | * Per the spec: 30 | *

34 | * 35 | * TODO: Mock context and verify that it's not used during validation. 36 | * 37 | * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.4" 38 | * 39 | * @author Carlos Vara 40 | */ 41 | public class AssertFalseValidatorTest { 42 | 43 | /** 44 | * Test {@link AssertFalseValidator} with null context. 45 | */ 46 | @Test 47 | public void testAssertFalseValidator() { 48 | AssertFalseValidator afv = new AssertFalseValidator(); 49 | assertFalse("True value validation must fail", afv.isValid(true, null)); 50 | assertTrue("False value validation must succeed", afv.isValid(false, null)); 51 | assertTrue("Null value validation must succeed", afv.isValid(null, null)); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/constraints/AssertTrueValidatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import static org.junit.Assert.assertFalse; 22 | import static org.junit.Assert.assertTrue; 23 | 24 | import org.junit.Test; 25 | 26 | /** 27 | * Checks correct behaviour of {@link AssertTrueValidator}. 28 | *

29 | * Per the spec: 30 | *

    31 | *
  • The annotated element must be true.
  • 32 | *
  • null elements are considered valid.
  • 33 | *
34 | * 35 | * TODO: Mock context and verify that it's not used during validation. 36 | * 37 | * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.3" 38 | * 39 | * @author Carlos Vara 40 | */ 41 | public class AssertTrueValidatorTest { 42 | 43 | /** 44 | * Test {@link AssertTrueValidator} with null context. 45 | */ 46 | @Test 47 | public void testAssertTrueValidator() { 48 | AssertTrueValidator atv = new AssertTrueValidator(); 49 | assertTrue("True value validation must succeed", atv.isValid(true, null)); 50 | assertFalse("False value validation must fail", atv.isValid(false, null)); 51 | assertTrue("Null value validation must succeed", atv.isValid(null, null)); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/constraints/FrenchZipcodeValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | 24 | /** 25 | * Description: not implemented (test only)
26 | */ 27 | public class FrenchZipcodeValidator implements ConstraintValidator { 28 | @Override 29 | public boolean isValid(Object object, ConstraintValidatorContext validationContext) { 30 | return null != object; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/constraints/HasStringValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.ConstraintValidator; 22 | import jakarta.validation.ConstraintValidatorContext; 23 | 24 | import org.apache.bval.util.ObjectUtils; 25 | 26 | /** 27 | * Description:
28 | */ 29 | public class HasStringValidator implements ConstraintValidator { 30 | private String[] values; 31 | 32 | @Override 33 | public void initialize(HasValue stringValues) { 34 | values = stringValues.value(); 35 | } 36 | 37 | @Override 38 | public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) { 39 | return s == null || ObjectUtils.arrayContains(values, s); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/constraints/HasValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.Constraint; 22 | import jakarta.validation.Payload; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 27 | import static java.lang.annotation.ElementType.FIELD; 28 | import static java.lang.annotation.ElementType.METHOD; 29 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 30 | 31 | /** 32 | * Description: allow distinct string values for element (like enums)
33 | */ 34 | @Target({ ANNOTATION_TYPE, METHOD, FIELD }) 35 | @Constraint(validatedBy = { HasStringValidator.class }) 36 | @Retention(RUNTIME) 37 | public @interface HasValue { 38 | String[] value(); 39 | 40 | String message() default "Wrong value, must be one of {value}"; 41 | 42 | Class[] groups() default {}; 43 | 44 | Class[] payload() default {}; 45 | } 46 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/constraints/NotNullValidatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import static org.junit.Assert.assertFalse; 22 | import static org.junit.Assert.assertTrue; 23 | 24 | import org.junit.Test; 25 | 26 | /** 27 | * Checks correct behaviour of {@link NotNullValidator}. 28 | *

29 | * Per the spec: 30 | *

    31 | *
  • The annotated element must not be null.
  • 32 | *
33 | * 34 | * TODO: Mock context and verify that it's not used during validation. 35 | * 36 | * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.2" 37 | * 38 | * @author Carlos Vara 39 | */ 40 | public class NotNullValidatorTest { 41 | 42 | /** 43 | * Test {@link NotNullValidator} with null context. 44 | */ 45 | @Test 46 | public void testNotNullValidator() { 47 | NotNullValidator nnv = new NotNullValidator(); 48 | assertTrue("Non null value validation must succeed", nnv.isValid("hello", null)); 49 | assertFalse("Null value validation must fail", nnv.isValid(null, null)); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/constraints/NullValidatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import static org.junit.Assert.assertFalse; 22 | import static org.junit.Assert.assertTrue; 23 | 24 | import org.junit.Test; 25 | 26 | /** 27 | * Checks correct behaviour of {@link NullValidator}. 28 | *

29 | * Per the spec: 30 | *

    31 | *
  • The annotated element must be null.
  • 32 | *
33 | * 34 | * TODO: Mock context and verify that it's not used during validation. 35 | * 36 | * @see "bean_validation-1_0_CR1-pfd-spec#Chapter6#Example6.1" 37 | * 38 | * @author Carlos Vara 39 | */ 40 | public class NullValidatorTest { 41 | 42 | /** 43 | * Test {@link AssertFalseValidator} with null context. 44 | */ 45 | @Test 46 | public void testNullValidator() { 47 | NullValidator nv = new NullValidator(); 48 | assertTrue("Null value validation must succeed", nv.isValid(null, null)); 49 | assertFalse("Non null value validation must fail", nv.isValid("hello", null)); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/constraints/Password.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.Constraint; 22 | import jakarta.validation.Payload; 23 | import jakarta.validation.constraints.NotNull; 24 | import jakarta.validation.constraints.Size; 25 | import java.lang.annotation.Retention; 26 | 27 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 28 | 29 | /** 30 | * Description:
31 | * User: roman.stumm
32 | * Date: 01.04.2008
33 | * Time: 12:02:06
34 | */ 35 | @NotEmpty 36 | @NotNull 37 | @Size(min = 4, max = 5) 38 | @Retention(RUNTIME) 39 | @Constraint(validatedBy = {}) 40 | // test that Password is validated although only combined constraints exists, no own implementation 41 | public @interface Password { 42 | Class[] groups() default {}; 43 | 44 | String message() default "Wrong password"; 45 | 46 | int robustness() default 8; 47 | 48 | Class[] payload() default {}; 49 | } 50 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.constraints; 20 | 21 | import jakarta.validation.Constraint; 22 | import jakarta.validation.Payload; 23 | import java.lang.annotation.Documented; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.Target; 26 | 27 | import static java.lang.annotation.ElementType.TYPE; 28 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 29 | 30 | /** 31 | * not implemented! simple dummy implemenation for tests only! 32 | */ 33 | @Documented 34 | @Constraint(validatedBy = ZipCodeCityCoherenceValidator.class) 35 | @Target({ TYPE }) 36 | @Retention(RUNTIME) 37 | public @interface ZipCodeCityCoherence { 38 | String message() default "{validator.zipCodeCityCoherence}"; 39 | 40 | Class[] groups() default {}; 41 | 42 | Class[] payload() default {}; 43 | } 44 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/FooTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr; 20 | 21 | import java.util.ArrayList; 22 | import java.util.Collection; 23 | import java.util.Set; 24 | 25 | import jakarta.validation.ConstraintViolation; 26 | import jakarta.validation.Valid; 27 | import jakarta.validation.constraints.NotNull; 28 | 29 | import org.junit.Before; 30 | import org.junit.Test; 31 | 32 | /** 33 | * Description:
34 | */ 35 | public class FooTest extends ValidationTestBase { 36 | 37 | @Valid 38 | private Collection foos = new ArrayList(); 39 | 40 | @Before 41 | public void setup() { 42 | foos.add(new Foo("foo1")); 43 | foos.add(null); 44 | foos.add(new Foo("foo3")); 45 | } 46 | 47 | public static class Foo { 48 | @NotNull 49 | public String bar; 50 | 51 | public Foo(String bar) { 52 | this.bar = bar; 53 | } 54 | } 55 | 56 | @Test 57 | public void testValidation() { 58 | FooTest t = new FooTest(); 59 | 60 | Set> errors = validator.validate(t); 61 | System.out.println("got errors:"); 62 | for (ConstraintViolation error : errors) { 63 | System.out.println(error.getPropertyPath()); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/LiskovTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr; 20 | 21 | import jakarta.validation.Validation; 22 | import jakarta.validation.ValidatorFactory; 23 | import jakarta.validation.constraints.NotNull; 24 | 25 | import org.junit.Test; 26 | 27 | public class LiskovTest { 28 | @Test 29 | public void testBVal167() { 30 | try (final ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) { 31 | factory.getValidator().getConstraintsForClass(Impl.class); 32 | } 33 | } 34 | 35 | public interface Api { 36 | String read(@NotNull String key); 37 | } 38 | 39 | public interface Api2 extends Api { 40 | @Override 41 | String read(String key); 42 | } 43 | 44 | public static abstract class Base implements Api { 45 | @Override 46 | public String read(final String key) { 47 | return null; 48 | } 49 | } 50 | 51 | public static class Impl extends Base implements Api2 { 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/ValidationTestBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr; 20 | 21 | import java.util.Locale; 22 | 23 | import jakarta.validation.Validation; 24 | import jakarta.validation.Validator; 25 | import jakarta.validation.ValidatorFactory; 26 | 27 | import org.junit.Before; 28 | import org.junit.BeforeClass; 29 | 30 | public abstract class ValidationTestBase { 31 | protected static ValidatorFactory factory; 32 | 33 | @BeforeClass 34 | public static void setupValidatorFactory() { 35 | factory = Validation.buildDefaultValidatorFactory(); 36 | ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH); 37 | } 38 | 39 | /** 40 | * Validator instance to test 41 | */ 42 | protected Validator validator; 43 | 44 | @Before 45 | public void setUp() throws Exception { 46 | validator = createValidator(); 47 | } 48 | 49 | /** 50 | * Create the validator instance. 51 | * 52 | * @return Validator 53 | */ 54 | protected Validator createValidator() { 55 | return factory.getValidator(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/AccessTestBusinessObjectSub.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import org.apache.bval.constraints.HasValue; 22 | 23 | /** 24 | * Description:
25 | */ 26 | public class AccessTestBusinessObjectSub extends AccessTestBusinessObject { 27 | private String var2, _var2; 28 | 29 | public void setVar2(String var2) { 30 | this.var2 = var2; 31 | } 32 | 33 | public void setvar2(String _var2) { 34 | this._var2 = _var2; 35 | } 36 | 37 | public AccessTestBusinessObjectSub(String var1) { 38 | super(var1); 39 | } 40 | 41 | // getVar1() is called on subclass, although annotated on superclass 42 | @Override 43 | public String getVar1() { 44 | return var1; 45 | } 46 | 47 | //// test that getvar2() is called, not getVar2() 48 | 49 | @HasValue("5") 50 | public String getvar2() { 51 | return _var2; 52 | } 53 | 54 | @HasValue("6") 55 | public String getVar2() { 56 | return var2; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/BusinessAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import jakarta.validation.constraints.NotNull; 22 | 23 | /** 24 | * Description:
25 | */ 26 | public class BusinessAddress extends Address { 27 | private String company; 28 | 29 | @NotNull 30 | public String getCompany() { 31 | return company; 32 | } 33 | 34 | public void setCompany(String company) { 35 | this.company = company; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/CompanyAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import org.apache.bval.constraints.CompanyEmail; 22 | 23 | /** 24 | * Description:
25 | */ 26 | public class CompanyAddress { 27 | @CompanyEmail 28 | private String email; 29 | 30 | public CompanyAddress() { 31 | } 32 | 33 | public CompanyAddress(String email) { 34 | this.email = email; 35 | } 36 | 37 | // do not provided getters & setters to test that value access 38 | // of combined constraints directly use the private field 'email' 39 | } 40 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/Continent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package org.apache.bval.jsr.example; 21 | 22 | import jakarta.validation.Valid; 23 | import jakarta.validation.constraints.NotNull; 24 | import java.util.HashSet; 25 | import java.util.Set; 26 | 27 | /** 28 | * A continent has a name and a set of {@link Country}s. 29 | * 30 | * @author Carlos Vara 31 | */ 32 | public class Continent { 33 | 34 | @NotNull 35 | public String name; 36 | 37 | @Valid 38 | public Set countries = new HashSet(); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/Country.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import jakarta.validation.constraints.NotNull; 22 | import jakarta.validation.constraints.Size; 23 | 24 | public class Country { 25 | @NotNull 26 | private String name; 27 | @Size(max = 2) 28 | private String ISO2Code; 29 | @Size(max = 3) 30 | private String ISO3Code; 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public String getISO2Code() { 41 | return ISO2Code; 42 | } 43 | 44 | public void setISO2Code(String ISO2Code) { 45 | this.ISO2Code = ISO2Code; 46 | } 47 | 48 | public String getISO3Code() { 49 | return ISO3Code; 50 | } 51 | 52 | public void setISO3Code(String ISO3Code) { 53 | this.ISO3Code = ISO3Code; 54 | } 55 | } -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/Employee.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | /** 22 | * Description:
23 | */ 24 | public class Employee implements Person { 25 | private String firstName, lastName; 26 | 27 | public Employee(String firstN, String lastN) { 28 | this.firstName = firstN; 29 | this.lastName = lastN; 30 | } 31 | 32 | @Override 33 | public String getFirstName() { 34 | return firstName; 35 | } 36 | 37 | @Override 38 | public String getMiddleName() { 39 | return null; // not supported 40 | } 41 | 42 | @Override 43 | public String getLastName() { 44 | return lastName; 45 | } 46 | 47 | public void setFirstName(String firstName) { 48 | this.firstName = firstName; 49 | } 50 | 51 | public void setLastName(String lastName) { 52 | this.lastName = lastName; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/Engine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import jakarta.validation.constraints.Pattern; 22 | 23 | public class Engine { 24 | // TODO See about Windows bug with container @ Field#getAnnotatedType() 25 | // @Pattern.List({ 26 | @Pattern(regexp = "^[A-Z0-9-]+$", flags = Pattern.Flag.CASE_INSENSITIVE, message = "must contain alphabetical characters only")//, 27 | @Pattern(regexp = "^....-....-....$", message = "must match ....-....-....") 28 | // }) 29 | public String serialNumber; 30 | 31 | } -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/First.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | /** 22 | * Description:
23 | */ 24 | public interface First { 25 | } 26 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/FrenchAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import org.apache.bval.constraints.FrenchZipCode; 22 | 23 | /** 24 | * Description:
25 | */ 26 | public class FrenchAddress { 27 | @FrenchZipCode(size = 7) 28 | String zipCode; 29 | 30 | @FrenchZipCode 31 | String zipCode2 = "123456"; 32 | 33 | public FrenchAddress() { 34 | } 35 | 36 | public FrenchAddress(String zipCode) { 37 | this.zipCode = zipCode; 38 | } 39 | 40 | public String getZipCode() { 41 | return zipCode; 42 | } 43 | 44 | public void setZipCode(String zipCode) { 45 | this.zipCode = zipCode; 46 | } 47 | 48 | public String getZipCode2() { 49 | return zipCode2; 50 | } 51 | 52 | public void setZipCode2(String zipCode2) { 53 | this.zipCode2 = zipCode2; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/IllustratedBook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.bval.jsr.example; 18 | 19 | /** 20 | * Add a non-cascaded bean to a book. 21 | * 22 | * @version $Rev: 1004764 $ $Date: 2010-10-05 13:35:42 -0500 (Tue, 05 Oct 2010) $ 23 | */ 24 | public class IllustratedBook extends Book { 25 | private Person illustrator; 26 | 27 | /** 28 | * @return the illustrator 29 | */ 30 | public Person getIllustrator() { 31 | return illustrator; 32 | } 33 | 34 | /** 35 | * @param illustrator 36 | * the illustrator to set 37 | */ 38 | public void setIllustrator(Person illustrator) { 39 | this.illustrator = illustrator; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/Last.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | /** 22 | * Description:
23 | */ 24 | public interface Last { 25 | } 26 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/MaxTestEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import jakarta.validation.constraints.Max; 22 | import java.math.BigDecimal; 23 | 24 | /** 25 | * Description:
26 | */ 27 | public class MaxTestEntity { 28 | @Max(100) 29 | private String text; 30 | private String property; 31 | 32 | @Max(300) 33 | private long longValue; 34 | 35 | private BigDecimal decimalValue; 36 | 37 | public String getText() { 38 | return text; 39 | } 40 | 41 | @Max(200) 42 | public String getProperty() { 43 | return property; 44 | } 45 | 46 | public long getLongValue() { 47 | return longValue; 48 | } 49 | 50 | @Max(400) 51 | public BigDecimal getDecimalValue() { 52 | return decimalValue; 53 | } 54 | 55 | public void setText(String text) { 56 | this.text = text; 57 | } 58 | 59 | public void setProperty(String property) { 60 | this.property = property; 61 | } 62 | 63 | public void setLongValue(long longValue) { 64 | this.longValue = longValue; 65 | } 66 | 67 | public void setDecimalValue(BigDecimal decimalValue) { 68 | this.decimalValue = decimalValue; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/NoValidatorTestEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import jakarta.validation.constraints.Max; 22 | 23 | /** 24 | * Description:
25 | */ 26 | public class NoValidatorTestEntity { 27 | @Max(20) 28 | private Object anything; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/Person.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import org.apache.bval.constraints.NotEmpty; 22 | 23 | public interface Person { 24 | @NotEmpty 25 | String getFirstName(); 26 | 27 | String getMiddleName(); 28 | 29 | @NotEmpty 30 | String getLastName(); 31 | } -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/PreferredGuest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import jakarta.validation.constraints.Digits; 22 | 23 | public class PreferredGuest extends Customer { 24 | @Digits(integer = 10, fraction = 0) 25 | private String guestCreditCardNumber; 26 | 27 | public String getGuestCreditCardNumber() { 28 | return guestCreditCardNumber; 29 | } 30 | 31 | public void setGuestCreditCardNumber(String guestCreditCardNumber) { 32 | this.guestCreditCardNumber = guestCreditCardNumber; 33 | } 34 | } -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/RecursiveFoo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import org.apache.bval.constraints.NotEmpty; 22 | 23 | import jakarta.validation.Valid; 24 | import java.util.ArrayList; 25 | import java.util.Collection; 26 | 27 | /** 28 | * Description:
29 | */ 30 | public class RecursiveFoo { 31 | @NotEmpty 32 | @Valid 33 | Collection foos = new ArrayList(); 34 | 35 | public Collection getFoos() { 36 | return foos; 37 | } 38 | 39 | public void setFoos(Collection foos) { 40 | this.foos = foos; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/Second.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | /** 22 | * Description:
23 | */ 24 | public interface Second { 25 | } 26 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/SizeTestEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | import jakarta.validation.constraints.Size; 22 | import java.util.Collection; 23 | import java.util.Map; 24 | 25 | /** 26 | * Description:
27 | */ 28 | public class SizeTestEntity { 29 | @Size(max = 2) 30 | public Map map; 31 | @Size(max = 2) 32 | public Collection coll; 33 | @Size(max = 2) 34 | public String text; 35 | 36 | @Size(max = 2) 37 | public Object[] oa; 38 | @Size(max = 2) 39 | public byte[] ba; 40 | @Size(max = 2) 41 | public int[] it; 42 | @Size(max = 2) 43 | public Integer[] oa2; 44 | @Size(max = 2) 45 | public boolean[] boa; 46 | @Size(max = 2) 47 | public char[] ca; 48 | @Size(max = 2) 49 | public double[] da; 50 | @Size(max = 2) 51 | public float[] fa; 52 | @Size(max = 2) 53 | public long[] la; 54 | @Size(max = 2) 55 | public short[] sa; 56 | } 57 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/XmlEntitySampleBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | /** 22 | * Description: bean used to test constraints described in XML
23 | */ 24 | public class XmlEntitySampleBean { 25 | private String zipCode; 26 | private String valueCode; 27 | 28 | private String firstName; 29 | 30 | public String getFirstName() { 31 | return firstName; 32 | } 33 | 34 | public void setFirstName(String firstName) { 35 | this.firstName = firstName; 36 | } 37 | 38 | public String getZipCode() { 39 | return zipCode; 40 | } 41 | 42 | public void setZipCode(String zipCode) { 43 | this.zipCode = zipCode; 44 | } 45 | 46 | public String getValueCode() { 47 | return valueCode; 48 | } 49 | 50 | public void setValueCode(String valueCode) { 51 | this.valueCode = valueCode; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/example/ZipCodeCityCarrier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.example; 20 | 21 | /** 22 | * Description:
23 | */ 24 | public interface ZipCodeCityCarrier { 25 | String getZipCode(); 26 | 27 | String getCity(); 28 | } 29 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/Billable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | /** 22 | * Validation group checking a user is billable. 23 | * Example 3.1. Definition of groups 24 | */ 25 | public interface Billable { 26 | } 27 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/BillableCreditCard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | /** 22 | * Example 3.2. Assign groups to constraints. 23 | */ 24 | public class BillableCreditCard { 25 | } 26 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/BillableUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | import jakarta.validation.constraints.NotNull; 22 | import jakarta.validation.groups.Default; 23 | 24 | /** 25 | * User representation 26 | * Example 3.2. Assign groups to constraints. 27 | */ 28 | public class BillableUser { 29 | @NotNull 30 | private String firstname; 31 | 32 | @NotNull(groups = Default.class) 33 | private String lastname; 34 | 35 | @NotNull(groups = { Billable.class, BuyInOneClick.class }) 36 | private BillableCreditCard defaultCreditCard; 37 | 38 | public String getFirstname() { 39 | return firstname; 40 | } 41 | 42 | public void setFirstname(String firstname) { 43 | this.firstname = firstname; 44 | } 45 | 46 | public String getLastname() { 47 | return lastname; 48 | } 49 | 50 | public void setLastname(String lastname) { 51 | this.lastname = lastname; 52 | } 53 | 54 | public BillableCreditCard getDefaultCreditCard() { 55 | return defaultCreditCard; 56 | } 57 | 58 | public void setDefaultCreditCard(BillableCreditCard defaultCreditCard) { 59 | this.defaultCreditCard = defaultCreditCard; 60 | } 61 | } -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/BuyInOneClick.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | /** 22 | * customer can buy without any harrassing checking process. 23 | * Example 3.1. Definition of groups 24 | */ 25 | public interface BuyInOneClick { 26 | } 27 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/CyclicGroupSequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | import jakarta.validation.GroupSequence; 22 | 23 | /** 24 | * Description:
25 | */ 26 | @GroupSequence(value = CyclicGroupSequence.class) 27 | public interface CyclicGroupSequence { 28 | } 29 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/CyclicGroupSequence1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | import jakarta.validation.GroupSequence; 22 | 23 | /** 24 | * Description:
25 | */ 26 | @GroupSequence(value = CyclicGroupSequence2.class) 27 | public interface CyclicGroupSequence1 { 28 | } -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/CyclicGroupSequence2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | import jakarta.validation.GroupSequence; 22 | 23 | /** 24 | * Description:
25 | */ 26 | @GroupSequence(value = CyclicGroupSequence1.class) 27 | public interface CyclicGroupSequence2 { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/GClass1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | /** 22 | * Description:
23 | */ 24 | public class GClass1 implements GInterface1 { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/GClass2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | import jakarta.validation.GroupSequence; 22 | 23 | /** 24 | * Description:
25 | */ 26 | @GroupSequence({ GClass1.class, GClass2.class }) 27 | public class GClass2 extends GClass1 { 28 | } 29 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/GClass3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | import jakarta.validation.GroupSequence; 22 | 23 | /** 24 | * Description:
25 | */ 26 | @GroupSequence({ GClass3.class, GClass1.class }) 27 | public class GClass3 { 28 | } 29 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/GInterface1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups; 20 | 21 | import jakarta.validation.GroupSequence; 22 | 23 | /** 24 | * Description:
25 | */ 26 | @GroupSequence(GInterface1.class) 27 | public interface GInterface1 { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/implicit/Auditable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups.implicit; 20 | 21 | import jakarta.validation.constraints.NotNull; 22 | 23 | /** 24 | * Auditable object contract. 25 | * Example 3.7. Example of interface / group hosting constraints 26 | */ 27 | public interface Auditable { 28 | @NotNull 29 | String getCreationDate(); 30 | 31 | @NotNull 32 | String getLastUpdate(); 33 | 34 | @NotNull 35 | String getLastModifier(); 36 | 37 | @NotNull 38 | String getLastReader(); 39 | } 40 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/inheritance/BillableUser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups.inheritance; 20 | 21 | import org.apache.bval.jsr.groups.Billable; 22 | import org.apache.bval.jsr.groups.BillableCreditCard; 23 | 24 | import jakarta.validation.constraints.NotNull; 25 | import jakarta.validation.groups.Default; 26 | 27 | /** 28 | * Description:
29 | */ 30 | public class BillableUser { 31 | @NotNull 32 | private String firstname; 33 | 34 | @NotNull(groups = Default.class) 35 | private String lastname; 36 | 37 | @NotNull(groups = { Billable.class }) 38 | private BillableCreditCard defaultCreditCard; 39 | 40 | public String getFirstname() { 41 | return firstname; 42 | } 43 | 44 | public void setFirstname(String firstname) { 45 | this.firstname = firstname; 46 | } 47 | 48 | public String getLastname() { 49 | return lastname; 50 | } 51 | 52 | public void setLastname(String lastname) { 53 | this.lastname = lastname; 54 | } 55 | 56 | public BillableCreditCard getDefaultCreditCard() { 57 | return defaultCreditCard; 58 | } 59 | 60 | public void setDefaultCreditCard(BillableCreditCard defaultCreditCard) { 61 | this.defaultCreditCard = defaultCreditCard; 62 | } 63 | } -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/inheritance/BuyInOneClick.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups.inheritance; 20 | 21 | import org.apache.bval.jsr.groups.Billable; 22 | 23 | import jakarta.validation.groups.Default; 24 | 25 | /** 26 | * Customer can buy without harrassing checking process. 27 | * spec: Example 3.3. Groups can inherit other groups 28 | */ 29 | public interface BuyInOneClick extends Default, Billable { 30 | } 31 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/groups/redefining/InvalidRedefinedDefaultGroupAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.groups.redefining; 20 | 21 | import jakarta.validation.GroupSequence; 22 | import jakarta.validation.constraints.NotNull; 23 | 24 | /** 25 | * If a @GroupSequence redefining the Default group for a class A does not 26 | * contain the group A, a GroupDefinitionException is raised when the class is 27 | * validated or when its metadata is requested. 28 | */ 29 | @GroupSequence({ Address.class, Address.HighLevelCoherence.class }) 30 | public class InvalidRedefinedDefaultGroupAddress { 31 | @NotNull(groups = Address.HighLevelCoherence.class) 32 | private String street; 33 | 34 | @NotNull 35 | private String city; 36 | 37 | /** 38 | * check coherence on the overall object 39 | * Needs basic checking to be green first 40 | */ 41 | public interface HighLevelCoherence { 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/xml/TestConstraintValidatorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.xml; 20 | 21 | import org.apache.bval.jsr.DefaultConstraintValidatorFactory; 22 | 23 | /** 24 | * Description:
25 | */ 26 | public class TestConstraintValidatorFactory extends DefaultConstraintValidatorFactory { 27 | } 28 | -------------------------------------------------------------------------------- /bval-jsr/src/test/java/org/apache/bval/jsr/xml/TestMessageInterpolator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.jsr.xml; 20 | 21 | import org.apache.bval.jsr.DefaultMessageInterpolator; 22 | 23 | /** 24 | * Description:
25 | */ 26 | public class TestMessageInterpolator extends DefaultMessageInterpolator { 27 | } 28 | -------------------------------------------------------------------------------- /bval-jsr/src/test/resources/META-INF/services/jakarta.el.ExpressionFactory: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | org.apache.bval.jsr.DelegateExpressionFactory 18 | -------------------------------------------------------------------------------- /bval-jsr/src/test/resources/ValidationMessages.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | # standard messages 19 | jakarta.validation.constraints.Pattern.message=must match "{regexp}" 20 | 21 | # custom messages (examples) for validation-api-1.0.Beta4 22 | test.validator.creditcard=credit card is not valid 23 | 24 | # custom messages (examples) for validation-api-1.0.CR1 25 | validator.creditcard=credit card is not valid 26 | 27 | recursive.interpolation.1={recursive.interpolation.2} 28 | recursive.interpolation.2={jakarta.validation.constraints.Pattern.message} 29 | -------------------------------------------------------------------------------- /bval-jsr/src/test/resources/sample-validation.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 23 | org.apache.bval.jsr.ApacheValidationProvider 24 | org.apache.bval.jsr.xml.TestMessageInterpolator 25 | org.apache.bval.jsr.resolver.SimpleTraversableResolver 26 | org.apache.bval.jsr.xml.TestConstraintValidatorFactory 27 | sample-constraints.xml 28 | test-prop-value 29 | 30 | -------------------------------------------------------------------------------- /bval-jsr/src/test/resources/sample-validation11.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 24 | org.apache.bval.jsr.ApacheValidationProvider 25 | org.apache.bval.jsr.xml.TestMessageInterpolator 26 | org.apache.bval.jsr.resolver.SimpleTraversableResolver 27 | org.apache.bval.jsr.xml.TestConstraintValidatorFactory 28 | sample-constraints.xml 29 | test-prop-value 30 | 31 | -------------------------------------------------------------------------------- /bval-jsr/src/test/resources/sample-validation2.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 24 | org.apache.bval.jsr.ApacheValidationProvider 25 | org.apache.bval.jsr.xml.TestMessageInterpolator 26 | org.apache.bval.jsr.resolver.SimpleTraversableResolver 27 | org.apache.bval.jsr.xml.TestConstraintValidatorFactory 28 | sample-constraints.xml 29 | test-prop-value 30 | 31 | -------------------------------------------------------------------------------- /bval-jsr/src/test/resources/sample-validation3.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 23 | 24 | org.apache.bval.jsr.ApacheValidationProvider 25 | org.apache.bval.jsr.xml.TestMessageInterpolator 26 | org.apache.bval.jsr.resolver.SimpleTraversableResolver 27 | org.apache.bval.jsr.xml.TestConstraintValidatorFactory 28 | sample-constraints.xml 29 | test-prop-value 30 | 31 | -------------------------------------------------------------------------------- /bval-jsr/src/test/resources/sample-validation31.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 23 | 24 | org.apache.bval.jsr.ApacheValidationProvider 25 | org.apache.bval.jsr.xml.TestMessageInterpolator 26 | org.apache.bval.jsr.resolver.SimpleTraversableResolver 27 | org.apache.bval.jsr.xml.TestConstraintValidatorFactory 28 | sample-constraints.xml 29 | test-prop-value 30 | 31 | -------------------------------------------------------------------------------- /bval-tck/src/main/java/org/apache/bval/arquillian/LogTckFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.bval.arquillian; 20 | 21 | import java.io.PrintWriter; 22 | import java.io.StringWriter; 23 | import java.util.logging.LogRecord; 24 | import java.util.logging.SimpleFormatter; 25 | 26 | public class LogTckFormatter extends SimpleFormatter { 27 | @Override 28 | public String format(final LogRecord record) { 29 | final String message = formatMessage(record); 30 | String throwable = ""; 31 | if (record.getThrown() != null) { 32 | final StringWriter sw = new StringWriter(); 33 | final PrintWriter pw = new PrintWriter(sw); 34 | pw.println(); 35 | record.getThrown().printStackTrace(pw); 36 | pw.close(); 37 | throwable = sw.toString(); 38 | } 39 | return String.format("[%s] %s%n%s", record.getLevel(), message, throwable); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bval-tck/src/main/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension: -------------------------------------------------------------------------------- 1 | org.apache.bval.arquillian.BValArquillianExtension 2 | -------------------------------------------------------------------------------- /bval-tck/src/main/resources/jndi.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | java.naming.factory.initial = org.apache.bval.arquillian.jndi.BValJndiFactory 18 | -------------------------------------------------------------------------------- /bval-tck/src/test/beanvalidation-tck-tests-suite.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /bval-tck/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension: -------------------------------------------------------------------------------- 1 | org.apache.bval.tck.TCKSuiteOWBEnhancements 2 | -------------------------------------------------------------------------------- /bval-tck/src/test/resources/arquillian.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 22 | 23 | 24 | true 25 | META-INF/services/jakarta.validation.spi.ValidationProvider 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /bval-tck/src/test/resources/logging.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | .level= INFO 18 | handlers = java.util.logging.ConsoleHandler 19 | java.util.logging.ConsoleHandler.level = INFO 20 | java.util.logging.ConsoleHandler.formatter =org.apache.bval.arquillian.LogTckFormatter 21 | org.apache.webbeans.arquillian.standalone.OwbArquillianScannerService.level = WARNING 22 | -------------------------------------------------------------------------------- /bval-tck/work-tests-suite.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 22 | 23 | org.apache.maven.skins 24 | maven-fluido-skin 25 | 1.7 26 | 27 | 28 | images/bval-bean-small.png 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | false 41 | true 42 | 43 | 44 | --------------------------------------------------------------------------------