org.hibernate.validator.constraints.impl
Class SizeValidatorForString

java.lang.Object
  extended by org.hibernate.validator.constraints.impl.SizeValidatorForString
All Implemented Interfaces:
ConstraintValidator<Size,String>

public class SizeValidatorForString
extends Object
implements ConstraintValidator<Size,String>

Check that a string's length is between min and max.

Author:
Emmanuel Bernard, Gavin King, Hardy Ferentschik

Constructor Summary
SizeValidatorForString()
           
 
Method Summary
 void initialize(Size parameters)
           
 boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext)
          Checks the length of the specified string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SizeValidatorForString

public SizeValidatorForString()
Method Detail

initialize

public void initialize(Size parameters)
Specified by:
initialize in interface ConstraintValidator<Size,String>

isValid

public boolean isValid(String s,
                       ConstraintValidatorContext constraintValidatorContext)
Checks the length of the specified string.

Specified by:
isValid in interface ConstraintValidator<Size,String>
Parameters:
s - The string to validate.
constraintValidatorContext - context in which the constraint is evaluated.
Returns:
Returns true if the string is null or the length of s between the specified min and max values (inclusive), false otherwise.


Copyright © 2007-2010 Red Hat Middleware, LLC. All Rights Reserved