Author: mrdon
Date: Thu Apr 27 22:34:08 2006
New Revision: 397767
URL: http://svn.apache.org/viewcvs?rev=397767&view=rev
Log:
Adding better string length handling
STR-2724
Modified:
struts/action/trunk/core/src/main/java/org/apache/struts/validator/FieldChecks.java
Modified:
struts/action/trunk/core/src/main/java/org/apache/struts/validator/FieldChecks.java
URL:
http://svn.apache.org/viewcvs/struts/action/trunk/core/src/main/java/org/apache/struts/validator/FieldChecks.java?rev=397767&r1=397766&r2=397767&view=diff
==============================================================================
---
struts/action/trunk/core/src/main/java/org/apache/struts/validator/FieldChecks.java
(original)
+++
struts/action/trunk/core/src/main/java/org/apache/struts/validator/FieldChecks.java
Thu Apr 27 22:34:08 2006
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * Copyright 2000-2005 The Apache Software Foundation.
+ * Copyright 2000-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1103,7 +1103,17 @@
request, true);
int max = Integer.parseInt(maxVar);
- if (!GenericValidator.maxLength(value, max)) {
+ boolean isValid = false;
+ String endLth = Resources.getVarValue("lineEndLength", field,
+ validator, request, false);
+ if (GenericValidator.isBlankOrNull(endLth)) {
+ isValid = GenericValidator.maxLength(value, max);
+ } else {
+ isValid = GenericValidator.maxLength(value, max,
+ Integer.parseInt(endLth));
+ }
+
+ if (!isValid) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va,
field));
@@ -1149,7 +1159,17 @@
request, true);
int min = Integer.parseInt(minVar);
- if (!GenericValidator.minLength(value, min)) {
+ boolean isValid = false;
+ String endLth = Resources.getVarValue("lineEndLength", field,
+ validator, request, false);
+ if (GenericValidator.isBlankOrNull(endLth)) {
+ isValid = GenericValidator.minLength(value, min);
+ } else {
+ isValid = GenericValidator.minLength(value, min,
+ Integer.parseInt(endLth));
+ }
+
+ if (!isValid) {
errors.add(field.getKey(),
Resources.getActionMessage(validator, request, va,
field));
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]