org.owasp.esapi.reference.validation
Class IntegerValidationRule

java.lang.Object
  extended by org.owasp.esapi.reference.validation.BaseValidationRule
      extended by org.owasp.esapi.reference.validation.IntegerValidationRule
All Implemented Interfaces:
ValidationRule

public class IntegerValidationRule
extends BaseValidationRule

A validator performs syntax and possibly semantic validation of a single piece of data from an untrusted source.

Since:
June 1, 2007
Author:
Jeff Williams (jeff.williams .at. aspectsecurity.com) Aspect Security
See Also:
Validator

Field Summary
 
Fields inherited from class org.owasp.esapi.reference.validation.BaseValidationRule
allowNull, encoder
 
Constructor Summary
IntegerValidationRule(java.lang.String typeName, Encoder encoder)
           
IntegerValidationRule(java.lang.String typeName, Encoder encoder, int minValue, int maxValue)
           
 
Method Summary
 java.lang.Integer getValid(java.lang.String context, java.lang.String input)
          Parse the input, throw exceptions if validation fails
 java.lang.Integer sanitize(java.lang.String context, java.lang.String input)
          The method is similar to ValidationRuile.getSafe except that it returns a harmless object that may or may not have any similarity to the original input (in some cases you may not care).
 
Methods inherited from class org.owasp.esapi.reference.validation.BaseValidationRule
assertValid, charArrayToSet, getEncoder, getSafe, getTypeName, getValid, isAllowNull, isValid, setAllowNull, setEncoder, setTypeName, whitelist, whitelist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerValidationRule

public IntegerValidationRule(java.lang.String typeName,
                             Encoder encoder)

IntegerValidationRule

public IntegerValidationRule(java.lang.String typeName,
                             Encoder encoder,
                             int minValue,
                             int maxValue)
Method Detail

getValid

public java.lang.Integer getValid(java.lang.String context,
                                  java.lang.String input)
                           throws ValidationException
Description copied from interface: ValidationRule
Parse the input, throw exceptions if validation fails

Parameters:
context - for logging
input - the value to be parsed
Returns:
a validated value
Throws:
ValidationException - if any validation rules fail

sanitize

public java.lang.Integer sanitize(java.lang.String context,
                                  java.lang.String input)
Description copied from class: BaseValidationRule
The method is similar to ValidationRuile.getSafe except that it returns a harmless object that may or may not have any similarity to the original input (in some cases you may not care). In most cases this should be the same as the getSafe method only instead of throwing an exception, return some default value.

Specified by:
sanitize in class BaseValidationRule
Returns:
a parsed version of the input or a default value.


Copyright © 2011 The Open Web Application Security Project (OWASP). All Rights Reserved.