org.openmrs.validator
Class UserValidator

java.lang.Object
  extended by org.openmrs.validator.UserValidator
All Implemented Interfaces:
org.springframework.validation.Validator

@Handler(supports=User.class,
         order=50)
public class UserValidator
extends java.lang.Object
implements org.springframework.validation.Validator

Validates attributes on the User object

Since:
1.5

Field Summary
protected  org.apache.commons.logging.Log log
          Log for this class and subclasses
 
Constructor Summary
UserValidator()
           
 
Method Summary
 boolean isUserNameValid(java.lang.String username)
          Convenience method to check the given username against the regular expression.
 boolean supports(java.lang.Class c)
          Determines if the command object being submitted is a valid type
 void validate(java.lang.Object obj, org.springframework.validation.Errors errors)
          Checks the form object for any inconsistencies/errors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Log for this class and subclasses

Constructor Detail

UserValidator

public UserValidator()
Method Detail

supports

public boolean supports(java.lang.Class c)
Determines if the command object being submitted is a valid type

Specified by:
supports in interface org.springframework.validation.Validator
See Also:
Validator.supports(java.lang.Class)

validate

public void validate(java.lang.Object obj,
                     org.springframework.validation.Errors errors)
Checks the form object for any inconsistencies/errors

Specified by:
validate in interface org.springframework.validation.Validator
See Also:
Validator.validate(java.lang.Object, org.springframework.validation.Errors)
Expected behavior:
fail validation if retired and retireReason is null or empty or whitespace, pass validation if all required fields have proper values

isUserNameValid

public boolean isUserNameValid(java.lang.String username)
Convenience method to check the given username against the regular expression.

A valid username will have following:
  • Begins with Alphanumeric characters
  • only followed by more alphanumeric characters (may include . - _)
  • can be at most 50 characters
  • minimum 2 chars case-insensitive Examples:
  • The following username will pass validation: A123_.-XYZ9

    Parameters:
    username - the username string to check
    Returns:
    true if the username is ok
    Expected behavior:
    validate username with only alpha numerics, validate username with alpha dash and underscore, validate username with alpha dash underscore and dot, validate username with exactly max size name, not validate username with less than minimumLength, not validate username with invalid character, not validate username with more than maximum size, validate when username is null, validate when username is the empty string, not validate when username is whitespace only

  • OpenMRS-1.7.x

    Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change