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 | *
31 | * - The annotated element must be false.
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.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 extends Payload>[] 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 extends Payload>[] 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 extends Payload>[] 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 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | false
41 | true
42 |
43 |
44 |
--------------------------------------------------------------------------------