On 5/22/07, Matthias Wessendorf <[EMAIL PROTECTED]> wrote:
On 5/22/07, Adam Winer <[EMAIL PROTECTED]> wrote: > The Trinidad subclass of LengthValidator needs some work. > Changes I plan to make - feedback appreciated: > > - The messages are copied from the LongRangeValidator, so > we say "Enter a value greater than or equal to 5" instead > of "Enter a value of 5 or more characters". (I'll use the latter)yup > - If min and max are the same, we don't have a custom message, > so you'd get something like "Enter a value between 5 and 5 > characters". Looks silly. So, in addition to > LengthValidator.NOT_IN_RANGE, I'll add LengthValidator.EXACT. indeed > - The override of Validate assumes the value is a Number!, and > lots of Javadoc is cut-and-pasted from LongRangeValidator, > it would seem... Thankfully, there's an instanceof check, > so no ClassCastExceptions but this code has to just be broken... LongRangeVali ? or LengthVali (see subject) the myfaces LengthVali does: int length = value instanceof String ? ((String)value).length() : value.toString().length();
I meant the Trinidad subclass of javax.faces.validator.LengthValidator - sorry for the confusion. The MyFaces Core LengthValidator is fine, though I'd just write that line as: value.toString().length(); ... as String.toString() is a noop. I basically never cast to String, I always call toString() if the value isn't null. -- Adam
