Adds a custom data validator using regex patterns or callback function
static null
addDataValidator
( $name, mixed $pattern, string $key)
-
string
$key: Key name or input value (direct input must be enabled)
-
mixed
$pattern: Optional. Regex pattern or a callback function
-
$name
RaxanDataSanitizer
__construct
([ $array = null], [ $charset = null])
Adds a custom data validator using regex patterns or callback function
Used as a wrapper to the RaxanDataSanitizer::addDataValidator() static method
void
addValidator
( $name, $pattern)
Returns an alphanumeric value for the specified field name
string
alphanumericVal
( $key)
Returns a date value for the specified field name
mixed
dateVal
( $key, [string $format = null])
Returns sanitized email address for the selected field
string
emailVal
( $key)
Enables direct data input. This will allow values to be passed directly to validator functions.
void
enableDirectInput
([boolean $state = true])
-
boolean
$state: Defaults to true
Returns text with special xml/html characters encoded for the selected field
string
escapeVal
( $key)
Returns the content of an uploaded file based on the selected field name
string
fileContent
(string $fld)
-
string
$fld: Form element field name
Copies an uploaded files (based on the selected field name) to the specified destination.
boolean
fileCopy
(string $fld, string $dest)
-
string
$fld: Form element field name
-
string
$dest: Destination path and file name
Returns a total number of file uploaded
int
fileCount
()
Resamples (convert/resize) the uploaded image. You can specify a new width, height and type
boolean
fileImageResample
(string $fld, $w, $h, [ $type = null])
-
string
$fld: Form element field name
-
$w
-
$h
-
$type
Returns an array containing the width, height and type for the uploaded image file
mixed
fileImageSize
(string $fld)
-
string
$fld: Form element field name
Moves an uploaded files (based on the selected field name) to the specified destination.
boolean
fileMove
(string $fld, string $dest)
-
string
$fld: Form element field name
-
string
$dest: Destination path and file name
Returns the original name of the uploaded file based on the selected field name
string
fileOrigName
(string $fld)
-
string
$fld: Form element field name
Returns the size of the uploaded file based on the selected field name
integer
fileSize
(string $fld)
-
string
$fld: Form element field name
Returns the temporary file name and path of the uploaded file based on the selected field name
string
fileTmpName
(string $fld)
-
string
$fld: Form element field name
Returns the file type (as reported by browser) of an uploaded file based on the selected field name
string
fileType
(string $fld)
-
string
$fld: Form element field name
Returns the file upload error code for uploaded file
string
fileUploadError
(string $fld)
-
string
$fld: Form element field name
Returns associative array of filtered/sanitized values
array
filterValues
([mixed $keyFields = null])
-
mixed
$keyFields: Optional. Comma (,) delimitted key/field names or associative array of field names and filter type. Default to all keys/fields with textVal filter applied
Converts input value/key to a float value
float
floatVal
( $key, [ $decimal = null])
Returns formated date value
string
formatDate
(string $key, [string $format = null])
-
string
$key: Key name or input value (direct input must be enabled)
-
string
$format: Date format
Returns formatted money value based on locale settings
string
formatMoney
(string $key, [int $decimal = null], [string $symbol = null])
-
string
$key: Key name or input value (direct input must be enabled)
-
int
$decimal: Optional. Total number of decimal places to return
-
string
$symbol: Optional. Currency symbol
Returns formatted number value based on locale settings
string
formatNumber
(string $key, [int $decimal = null])
-
string
$key: Key name or input value (direct input must be enabled)
-
int
$decimal: Optional. Total number of decimal places to return
Sanitized html by removing javascript tags and inline events
string
htmlVal
(string $key, [string $allowable = null], [string $allowStyle = true])
-
string
$key: Key name or input value (direct input must be enabled)
-
string
$allowable: Optional. Allowable html tags. Example <p><a>
-
string
$allowStyle: Optional. Allow css styles inside html. Defaults to true
Converts input value/key to an integer value
int
intVal
( $key)
Returns true if the selected field contains a valid date
boolean
isDate
(string $key, [string $format = null])
-
string
$key: Key name or input value (direct input must be enabled)
-
string
$format: Optional date input format. Accepts the same format as formatDate()
Returns true if the selected field contains a valid email address
boolean
isEmail
( $key)
Returns true if the selected field is numeric
boolean
isNumeric
(mixed $key, [float $min = null], [float $max = null])
-
mixed
$key: Key field name or value
-
float
$min: Optional. Minimum value
-
float
$max: Optional. Maximum value
Returns true if the selected field contains a valid url
boolean
isUrl
( $key)
Returns the length of the speicifed field value
int
length
( $key)
Returns matched characters
string
matchVal
(string $key, [string $pattern = '/[a-zA-Z0-9-.]/'])
-
string
$key: Key name or input value (direct input must be enabled)
-
string
$pattern: Optional Regex pattern. Defaults to /[a-zA-Z0-9-.]/
Sets the array source for the sanitizer
Remove html tags from input values
string
textVal
(string $key, [int $maxlength = null])
-
string
$key: Key name or input value (direct input must be enabled)
-
int
$maxlength: Optional. Length of text value to be returned
Converts input value/key to a valid timestamp
int
timestampVal
( $key)
Returns sanitized url for the selected field
string
urlVal
(string $key, [boolean $encoded = false])
-
string
$key: Key name or input value (direct input must be enabled)
-
boolean
$encoded: Optional. Encode url string. Defaults to false
Returns a value based on the specified key
mixed
value
( $key)
void
__call
( $name, $args)
Returns the sanitized text for the specified key. All html charcters will be removed.
String
__get
( $name)
Sets the value for a key to be sanitized or formatted.
Example: $format->keyName = 'Mary Jane
'; echo $format->textVal('keyName');
String
__set
( $name, $value)