API Documentation for: 1.1.1
Show:

Validate Class

Namespace: Canteen\Utilities

Utilities to help sanitize data. Located in the namespace Canteen\Utilities.

Item Index

Methods

Properties

Methods

verify

(
  • data
  • [type=null]
  • [suppressErrors=false]
)
Mixed static

Sanitize input data using the validation types above

Parameters:

  • data String | Array

    The data to be validated, can be an array of items

  • [type=null] RegExp optional

    The type of validation, defaults to Numeric. Can also be an array set of items

  • [suppressErrors=false] Boolean optional

    If we should suppress throwing errors

Returns:

Mixed:

If we don't verify and suppress errors, returns false, else returns the data

verifyMutli

(
  • data
  • types
  • [suppressErrors=false]
)
Mixed static

Verify multiple data with multiple types

Parameters:

  • data Array

    The associative array of data e.g. ['name'=>"something", 'title'=>"another"]

  • types Array

    The associate array of types e.g. ['name'=>Validate::NAMES, 'title'=>Validate::FULL_TEXT]

  • [suppressErrors=false] Boolean optional

    If we should suppress throwing errors

Returns:

Mixed:

False if anything doesn't verify or else returns data

Properties

ALPHA

RegExp final static

Validation Type: remove all non alpha characters, includes a-z, A-Z

ALPHA_NUMERIC

RegExp final static

Validation Type: remove all non alpha numeric characters, includes a-z, A-Z, 0-9

BOOLEAN

RegExp final static

Validation Type: booleans, includes 0-1

DECIMAL

RegExp final static

Validation Type: remove all non decimal characters, includes 0-9, .

EMAIL

RegExp final static

Validation Type: remove all non email characters, includes a-z, A-Z, 0-9, ., -, _, @

FILE_NAME

RegExp final static

Validation type: for file names, includes a-z, A-Z, 0-9, -, _, .

FULL_TEXT

RegExp final static

Validation Type: remove all non alpha numeric punctuation characters

MYSQL_DATE

RegExp final static

The valid mysql date format

NAMES

RegExp final static

Validation Type: for people's names, includes a-z, A-Z, -, .

NUMERIC

RegExp final static

Validation Type: remove all non numeric characters, includes 0-9

URI

RegExp final static

Validation Type: remove all non standard uri characters, includes a-z, A-Z, 0-9, -, _, ., /

URL

RegExp final static

Validation Type: remove all non standard URL characters, includes a-z, A-Z, 0-9, -, _, ., /, &, %, :, =