phpPeanuts  2.2.0
phpPeanuts framework
 All Data Structures Namespaces Files Functions Variables
Public Member Functions | Static Public Member Functions | Data Fields
PntValueValidator Class Reference

Inherited by ValueValidator.

Public Member Functions

 initFromProp ($prop)
 
 getNumberMaxValue ()
 
 getNumberMinValue ()
 
 getMaxValueFromMaxLength ()
 
 getErrorInvalidNumber ()
 
 validate ($value, $validateReadOnly=true)
 
 validate_min_max ($value, $minValue, $maxValue)
 
 validateBoolean ($value)
 
 validateNumber ($value)
 
 validateDate ($value)
 
 validateTime ($value)
 
 validateTimestamp ($value)
 
 validateEmail ($value)
 
 validateString ($value)
 
 validateObject ($value)
 

Static Public Member Functions

static getInternalCharset ()
 
static getInfiniteBig ()
 
static getInfiniteSmall ()
 
static getInfiniteDate ()
 
static getZeroDate ()
 
static getInfinity ($type)
 
static getInternalDateFormat ()
 
static getInternalTimestampFormat ()
 
static getInternalTimeFormat ()
 
static getInternalDecimalSeparator ()
 
static getDecimalPrecision ($maxLength)
 
static equal ($value, $reference, $type)
 
static getDerivedChangeConflictMessage ()
 

Data Fields

 $errorReadOnly ='no changes allowed'
 
 $errorTooHigh ='too high, max: '
 
 $errorTooLow ='too low, min: '
 
 $errorTooShort ='too short, min: '
 
 $errorTooLong ='too long, max: '
 
 $errorInvalidEmail ='invalid email address'
 
 $errorInvalidType ='invalid type: '
 
 $errorNotOfType ='value must be a: '
 
 $type
 
 $readOnly
 
 $minValue
 
 $maxValue
 
 $minLength
 
 $maxLength
 

Member Function Documentation

static equal (   $value,
  $reference,
  $type 
)
static
Returns
wheather the first primitive value is equal to the reference primitive value. Php's == operator sees null, false, '' and 0 as equal, but most databases don't. Php's === operater is so strict that automatic type conversion becomes useless. This function should return the same as a case sentitive = on database-stored values. expects a boolean or number
Parameters
mixed$valuethe value to compare
mixed$referencethe value to compare to
static getDecimalPrecision (   $maxLength)
static

only if type = 'number'.

Returns
number of decimals after the decimal separater, or null if none
Parameters
mixed$maxLengthint or string like '5,2'
static getDerivedChangeConflictMessage ( )
static
getErrorInvalidNumber ( )
static getInfiniteBig ( )
static
static getInfiniteDate ( )
static
static getInfiniteSmall ( )
static
static getInfinity (   $type)
static
static getInternalCharset ( )
static
Returns
String the character encoding of domain model strings. The naming is to be compatible with http request header "content-type: text/html; charset= " You should override this method on ValueValidator if you want to use a different encoding. If you do: Be aware that the database must support the same encoding. Be aware that length validation needs to be overridden on ValueValidator for multi byte character sets. Be aware that for character sets that can contain illegal characters, like UTF-8, you must extend either Site, StringConverter or ValueValidator to sanitized/validate all incoming characters otherwise your application may be vurnerable to injection (SQL, CSS) and string php's and the database's string functions may not work properly (some of them never work properly with multi byte characters unless you use mbstrings).
static getInternalDateFormat ( )
static
Returns
string the internal format used in properties, fields and the database
static getInternalDecimalSeparator ( )
static
Returns
the internal format used in properties, fields and the database internal representation is created without thousends separator
static getInternalTimeFormat ( )
static
static getInternalTimestampFormat ( )
static
Returns
string the internal format used in properties, fields and the database. this is compatible with MySql datetime
getMaxValueFromMaxLength ( )
getNumberMaxValue ( )
getNumberMinValue ( )
static getZeroDate ( )
static
initFromProp (   $prop)

Initialize this from the supplied PropertyDescriptor

Parameters
PntPropertyDescriptor$prop
validate (   $value,
  $validateReadOnly = true 
)
Returns
string error message if invalid, or null if valid If more types have to be added to the validation this method must be overridden.
Parameters
mixed$valueto be validated
boolean$validateReadOnlywheather to validate that readOnly propeties are not set
validate_min_max (   $value,
  $minValue,
  $maxValue 
)
validateBoolean (   $value)
validateDate (   $value)

string $value holding date in internal date format. Does not have to be valid for strToTime.

validateEmail (   $value)

RFC2822 defines the format for email addresses. But new RFCs (http://tools.ietf.org/html/rfc5321 and http://tools.ietf.org/html/rfc5322) replace 2821 and 2822. This validation is much more permissive then RFC's, except for the domain part, where it does not allow address literals or comments. This choice was based on the comments of mcv and Bear on http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx Tested Myself: e-mail adress with space in local part worked with catchall on a linux server if you need stricter validation you van override this method on ValueValidator. Consider the PHP function filter_var($email, FILTER_VALIDATE_EMAIL) (PHP 5.2.0 and up) or use its regexp, see http://svn.php.net/viewvc/php/php-src/trunk/ext/filter/logical_filters.c

validateNumber (   $value)
validateObject (   $value)
validateString (   $value)
validateTime (   $value)

string $value holding time in internal time format. Does not have to be valid for strToTime.

validateTimestamp (   $value)

string $value holding timestamp in internal timestamp format. Does not have to be valid for strToTime.

Field Documentation

$errorInvalidEmail ='invalid email address'
$errorInvalidType ='invalid type: '
$errorNotOfType ='value must be a: '
$errorReadOnly ='no changes allowed'
$errorTooHigh ='too high, max: '
$errorTooLong ='too long, max: '
$errorTooLow ='too low, min: '
$errorTooShort ='too short, min: '
$maxLength
$maxValue
$minLength
$minValue
$readOnly
$type

The documentation for this class was generated from the following file: