]> git.mxchange.org Git - jcoreee.git/blobdiff - src/org/mxchange/jcoreee/validator/BaseObjectValidator.java
Added flag allowNull to allow null ...
[jcoreee.git] / src / org / mxchange / jcoreee / validator / BaseObjectValidator.java
index 2114b9b00ecb2f453c94821ca423379ccd5c1418..1e27a4d79c2876b68be1112c8e7e32950fa3be4f 100644 (file)
@@ -62,10 +62,11 @@ public abstract class BaseObjectValidator implements Validator, Serializable {
         * @param component UIComponent instance
         * @param value Value to check
         * @param requiredFields Array of required field names (ending with)
+        * @param allowNull Wether null or empty values are allowed
         * <p>
         * @throws ValidatorException If something more horrible went wrong
         */
-       protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields) throws ValidatorException {
+       protected void preValidate (final FacesContext context, final UIComponent component, final Object value, final String[] requiredFields, boolean allowNull) throws ValidatorException {
                // Trace message
                //this.getLogger().logTrace(MessageFormat.format("preValidate: context={0},component={1},value={2},requiredFields={3} - CALLED!", context, component, value, Arrays.toString(requiredFields))); //NOI18N
 
@@ -89,7 +90,7 @@ public abstract class BaseObjectValidator implements Validator, Serializable {
                                isValidField = true;
 
                                // Is it null?
-                               if (null == value) {
+                               if ((!allowNull) && (null == value)) {
                                        // Value it null
                                        facesMessage = new FacesMessage(MessageFormat.format("Field {0} is null.", field)); //NOI18N
                                }