play.data.validation
Class Validation

java.lang.Object
  extended by play.data.validation.Validation

public class Validation
extends java.lang.Object


Nested Class Summary
static class Validation.ValidationResult
           
static class Validation.Validator
           
 
Constructor Summary
protected Validation()
           
 
Method Summary
static void addError(java.lang.String field, java.lang.String message, java.lang.String... variables)
          Add an error
static void clear()
           
static Validation current()
           
 Validation.ValidationResult email(java.lang.Object o)
           
static Validation.ValidationResult email(java.lang.String key, java.lang.Object o)
           
 Validation.ValidationResult equals(java.lang.Object o, java.lang.Object to)
           
static Validation.ValidationResult equals(java.lang.String key, java.lang.Object o, java.lang.String otherName, java.lang.Object to)
           
static Error error(java.lang.String field)
           
static java.util.List<Error> errors()
           
static java.util.List<Error> errors(java.lang.String field)
           
 java.util.Map<java.lang.String,java.util.List<Error>> errorsMap()
           
 Validation.ValidationResult future(java.lang.Object o)
           
 Validation.ValidationResult future(java.lang.Object o, java.util.Date reference)
           
static Validation.ValidationResult future(java.lang.String key, java.lang.Object o)
           
static Validation.ValidationResult future(java.lang.String key, java.lang.Object o, java.util.Date reference)
           
static java.util.Map<java.lang.String,java.util.List<Validation.Validator>> getValidators(java.lang.Class<?> clazz, java.lang.String name)
           
static java.util.List<Validation.Validator> getValidators(java.lang.Class<?> clazz, java.lang.String property, java.lang.String name)
           
static boolean hasError(java.lang.String field)
           
static boolean hasErrors()
           
 Validation.ValidationResult isTrue(java.lang.Object o)
           
static Validation.ValidationResult isTrue(java.lang.String key, java.lang.Object o)
           
static void keep()
          Keep errors for the next request (will be stored in a cookie)
 Validation.ValidationResult match(java.lang.Object o, java.lang.String pattern)
           
static Validation.ValidationResult match(java.lang.String key, java.lang.Object o, java.lang.String pattern)
           
 Validation.ValidationResult max(java.lang.Object o, double max)
           
static Validation.ValidationResult max(java.lang.String key, java.lang.Object o, double max)
           
 Validation.ValidationResult maxSize(java.lang.Object o, int maxSize)
           
static Validation.ValidationResult maxSize(java.lang.String key, java.lang.Object o, int maxSize)
           
 Validation.ValidationResult min(java.lang.Object o, double min)
           
static Validation.ValidationResult min(java.lang.String key, java.lang.Object o, double min)
           
 Validation.ValidationResult minSize(java.lang.Object o, int minSize)
           
static Validation.ValidationResult minSize(java.lang.String key, java.lang.Object o, int minSize)
           
 Validation.ValidationResult past(java.lang.Object o)
           
 Validation.ValidationResult past(java.lang.Object o, java.util.Date reference)
           
static Validation.ValidationResult past(java.lang.String key, java.lang.Object o)
           
static Validation.ValidationResult past(java.lang.String key, java.lang.Object o, java.util.Date reference)
           
 Validation.ValidationResult range(java.lang.Object o, double min, double max)
           
static Validation.ValidationResult range(java.lang.String key, java.lang.Object o, double min, double max)
           
 Validation.ValidationResult required(java.lang.Object o)
           
static Validation.ValidationResult required(java.lang.String key, java.lang.Object o)
           
 Validation.ValidationResult valid(java.lang.Object o)
           
static Validation.ValidationResult valid(java.lang.String key, java.lang.Object o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Validation

protected Validation()
Method Detail

current

public static Validation current()
Returns:
The current validation helper

errors

public static java.util.List<Error> errors()
Returns:
The list of all errors

errorsMap

public java.util.Map<java.lang.String,java.util.List<Error>> errorsMap()
Returns:
All errors keyed by field name

addError

public static void addError(java.lang.String field,
                            java.lang.String message,
                            java.lang.String... variables)
Add an error

Parameters:
field - Field name
message - Message key
variables - Message variables

hasErrors

public static boolean hasErrors()
Returns:
True if the current request has errors

error

public static Error error(java.lang.String field)
Parameters:
field - The field name
Returns:
First error related to this field

errors

public static java.util.List<Error> errors(java.lang.String field)
Parameters:
field - The field name
Returns:
All errors related to this field

keep

public static void keep()
Keep errors for the next request (will be stored in a cookie)


hasError

public static boolean hasError(java.lang.String field)
Parameters:
field - The field name
Returns:
True is there are errors related to this field

clear

public static void clear()

getValidators

public static java.util.Map<java.lang.String,java.util.List<Validation.Validator>> getValidators(java.lang.Class<?> clazz,
                                                                                                 java.lang.String name)

getValidators

public static java.util.List<Validation.Validator> getValidators(java.lang.Class<?> clazz,
                                                                 java.lang.String property,
                                                                 java.lang.String name)

required

public static Validation.ValidationResult required(java.lang.String key,
                                                   java.lang.Object o)

required

public Validation.ValidationResult required(java.lang.Object o)

min

public static Validation.ValidationResult min(java.lang.String key,
                                              java.lang.Object o,
                                              double min)

min

public Validation.ValidationResult min(java.lang.Object o,
                                       double min)

max

public static Validation.ValidationResult max(java.lang.String key,
                                              java.lang.Object o,
                                              double max)

max

public Validation.ValidationResult max(java.lang.Object o,
                                       double max)

future

public static Validation.ValidationResult future(java.lang.String key,
                                                 java.lang.Object o,
                                                 java.util.Date reference)

future

public Validation.ValidationResult future(java.lang.Object o,
                                          java.util.Date reference)

future

public static Validation.ValidationResult future(java.lang.String key,
                                                 java.lang.Object o)

future

public Validation.ValidationResult future(java.lang.Object o)

past

public static Validation.ValidationResult past(java.lang.String key,
                                               java.lang.Object o,
                                               java.util.Date reference)

past

public Validation.ValidationResult past(java.lang.Object o,
                                        java.util.Date reference)

past

public static Validation.ValidationResult past(java.lang.String key,
                                               java.lang.Object o)

past

public Validation.ValidationResult past(java.lang.Object o)

match

public static Validation.ValidationResult match(java.lang.String key,
                                                java.lang.Object o,
                                                java.lang.String pattern)

match

public Validation.ValidationResult match(java.lang.Object o,
                                         java.lang.String pattern)

email

public static Validation.ValidationResult email(java.lang.String key,
                                                java.lang.Object o)

email

public Validation.ValidationResult email(java.lang.Object o)

isTrue

public static Validation.ValidationResult isTrue(java.lang.String key,
                                                 java.lang.Object o)

isTrue

public Validation.ValidationResult isTrue(java.lang.Object o)

equals

public static Validation.ValidationResult equals(java.lang.String key,
                                                 java.lang.Object o,
                                                 java.lang.String otherName,
                                                 java.lang.Object to)

equals

public Validation.ValidationResult equals(java.lang.Object o,
                                          java.lang.Object to)

range

public static Validation.ValidationResult range(java.lang.String key,
                                                java.lang.Object o,
                                                double min,
                                                double max)

range

public Validation.ValidationResult range(java.lang.Object o,
                                         double min,
                                         double max)

minSize

public static Validation.ValidationResult minSize(java.lang.String key,
                                                  java.lang.Object o,
                                                  int minSize)

minSize

public Validation.ValidationResult minSize(java.lang.Object o,
                                           int minSize)

maxSize

public static Validation.ValidationResult maxSize(java.lang.String key,
                                                  java.lang.Object o,
                                                  int maxSize)

maxSize

public Validation.ValidationResult maxSize(java.lang.Object o,
                                           int maxSize)

valid

public static Validation.ValidationResult valid(java.lang.String key,
                                                java.lang.Object o)

valid

public Validation.ValidationResult valid(java.lang.Object o)


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly