You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bval.apache.org by si...@apache.org on 2012/01/07 23:28:51 UTC

svn commit: r1228744 - in /incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard: ./ AmericanExpress.java Diners.java Discover.java Mastercard.java Visa.java package-info.java

Author: simonetripodi
Date: Sat Jan  7 22:28:51 2012
New Revision: 1228744

URL: http://svn.apache.org/viewvc?rev=1228744&view=rev
Log:
added Credit Cards constraints, taking inspiration from apache commons-validations but implemented as constraints composition

Added:
    incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/
    incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/AmericanExpress.java   (with props)
    incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Diners.java   (with props)
    incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Discover.java   (with props)
    incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Mastercard.java   (with props)
    incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Visa.java   (with props)
    incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/package-info.java   (with props)

Added: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/AmericanExpress.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/AmericanExpress.java?rev=1228744&view=auto
==============================================================================
--- incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/AmericanExpress.java (added)
+++ incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/AmericanExpress.java Sat Jan  7 22:28:51 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.extras.constraints.creditcard;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.constraints.Pattern;
+
+import org.apache.bval.extras.constraints.checkdigit.Luhn;
+
+/**
+ * <p>
+ * --
+ * TODO - This class is NOT part of the bean_validation spec and might disappear
+ * as soon as a final version of the specification contains a similar functionality.
+ * --
+ * </p>
+ * Description: annotation to validate a java.io.File is a directory<br/>
+ */
+@Documented
+@Luhn
+@Pattern(regexp="^(3[47]\\d{13})$")
+@Constraint(validatedBy={})
+@Target( { FIELD, ANNOTATION_TYPE, PARAMETER } )
+@Retention( RUNTIME )
+public @interface AmericanExpress {
+
+    Class<?>[] groups() default {};
+
+    String message() default "{org.apache.bval.extras.constraints.creditcard.AmericanExpress.message}";
+
+    Class<? extends Payload>[] payload() default {};
+
+}

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/AmericanExpress.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/AmericanExpress.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/AmericanExpress.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Diners.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Diners.java?rev=1228744&view=auto
==============================================================================
--- incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Diners.java (added)
+++ incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Diners.java Sat Jan  7 22:28:51 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.extras.constraints.creditcard;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.constraints.Pattern;
+
+import org.apache.bval.extras.constraints.checkdigit.Luhn;
+
+/**
+ * <p>
+ * --
+ * TODO - This class is NOT part of the bean_validation spec and might disappear
+ * as soon as a final version of the specification contains a similar functionality.
+ * --
+ * </p>
+ * Description: annotation to validate a java.io.File is a directory<br/>
+ */
+@Documented
+@Luhn
+@Pattern(regexp="^(30[0-5]\\d{11}|3095\\d{10}|36\\d{12}|3[8-9]\\d{12})$")
+@Constraint(validatedBy={})
+@Target( { FIELD, ANNOTATION_TYPE, PARAMETER } )
+@Retention( RUNTIME )
+public @interface Diners {
+
+    Class<?>[] groups() default {};
+
+    String message() default "{org.apache.bval.extras.constraints.creditcard.Diners.message}";
+
+    Class<? extends Payload>[] payload() default {};
+
+}

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Diners.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Diners.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Diners.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Discover.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Discover.java?rev=1228744&view=auto
==============================================================================
--- incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Discover.java (added)
+++ incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Discover.java Sat Jan  7 22:28:51 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.extras.constraints.creditcard;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.constraints.Pattern;
+
+import org.apache.bval.extras.constraints.checkdigit.Luhn;
+
+/**
+ * <p>
+ * --
+ * TODO - This class is NOT part of the bean_validation spec and might disappear
+ * as soon as a final version of the specification contains a similar functionality.
+ * --
+ * </p>
+ * Description: annotation to validate a java.io.File is a directory<br/>
+ */
+@Documented
+@Luhn
+@Pattern(regexp="^((6011\\d{12})|(64[4-9]\\d{13})|(65\\d{14}))$")
+@Constraint(validatedBy={})
+@Target( { FIELD, ANNOTATION_TYPE, PARAMETER } )
+@Retention( RUNTIME )
+public @interface Discover {
+
+    Class<?>[] groups() default {};
+
+    String message() default "{org.apache.bval.extras.constraints.creditcard.Discover.message}";
+
+    Class<? extends Payload>[] payload() default {};
+
+}

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Discover.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Discover.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Discover.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Mastercard.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Mastercard.java?rev=1228744&view=auto
==============================================================================
--- incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Mastercard.java (added)
+++ incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Mastercard.java Sat Jan  7 22:28:51 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.extras.constraints.creditcard;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.constraints.Pattern;
+
+import org.apache.bval.extras.constraints.checkdigit.Luhn;
+
+/**
+ * <p>
+ * --
+ * TODO - This class is NOT part of the bean_validation spec and might disappear
+ * as soon as a final version of the specification contains a similar functionality.
+ * --
+ * </p>
+ * Description: annotation to validate a java.io.File is a directory<br/>
+ */
+@Documented
+@Luhn
+@Pattern(regexp="^(5[1-5]\\d{14})$")
+@Constraint(validatedBy={})
+@Target( { FIELD, ANNOTATION_TYPE, PARAMETER } )
+@Retention( RUNTIME )
+public @interface Mastercard {
+
+    Class<?>[] groups() default {};
+
+    String message() default "{org.apache.bval.extras.constraints.creditcard.Mastercard.message}";
+
+    Class<? extends Payload>[] payload() default {};
+
+}

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Mastercard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Mastercard.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Mastercard.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Visa.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Visa.java?rev=1228744&view=auto
==============================================================================
--- incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Visa.java (added)
+++ incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Visa.java Sat Jan  7 22:28:51 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.extras.constraints.creditcard;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import javax.validation.constraints.Pattern;
+
+import org.apache.bval.extras.constraints.checkdigit.Luhn;
+
+/**
+ * <p>
+ * --
+ * TODO - This class is NOT part of the bean_validation spec and might disappear
+ * as soon as a final version of the specification contains a similar functionality.
+ * --
+ * </p>
+ * Description: annotation to validate a java.io.File is a directory<br/>
+ */
+@Documented
+@Luhn
+@Pattern(regexp="^(4)(\\d{12}|\\d{15})$")
+@Constraint(validatedBy={})
+@Target( { FIELD, ANNOTATION_TYPE, PARAMETER } )
+@Retention( RUNTIME )
+public @interface Visa {
+
+    Class<?>[] groups() default {};
+
+    String message() default "{org.apache.bval.extras.constraints.creditcard.Visa.message}";
+
+    Class<? extends Payload>[] payload() default {};
+
+}

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Visa.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Visa.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/Visa.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/package-info.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/package-info.java?rev=1228744&view=auto
==============================================================================
--- incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/package-info.java (added)
+++ incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/package-info.java Sat Jan  7 22:28:51 2012
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * This package contains <i>Credit Card</i> validation routines.
+ */
+package org.apache.bval.extras.constraints.creditcard;

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-extras/src/main/java/org/apache/bval/extras/constraints/creditcard/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain