nyroFwk  0.2
Public Member Functions | Protected Member Functions | Protected Attributes
valid Class Reference
Inheritance diagram for valid:
object

Public Member Functions

 getValue ()
 
 setValue (&$value)
 
 addRule ($type, $prm=null, $msg=null)
 
 hasRule ($type)
 
 delRule ($type)
 
 getRules ()
 
 isValid ()
 
 isRequired ($val, $prm=null)
 
 isNumeric ($val, $prm=null)
 
 isInt ($val, $prm=null)
 
 isDifferent ($val, $prm=null)
 
 isIn ($val, $prm=null)
 
 isEqual ($val, $prm=null)
 
 isGroupedFields ($val, $prm=null)
 
 isAtLeastOneField ($val, $prm=null)
 
 isCallback ($val, $prm=null)
 
 isUrl ($val, $prm=null)
 
 isEmail ($val, $prm=null)
 
 isDbUnique ($val, array $prm)
 
 isDbExists ($val, array $prm)
 
 setMessage ($name, $msg)
 
 getErrors ()
 
 getAttr ($name)
 
 setAttr ($name, $value)
 
 getCfg ()
 

Protected Member Functions

 getMessage ($name)
 
 beforeInit ()
 
 afterInit ()
 

Protected Attributes

 $errors = array()
 
 $cfg
 

Detailed Description

Class using for validate a data

Definition at line 10 of file valid.class.php.

Member Function Documentation

◆ addRule()

addRule (   $type,
  $prm = null,
  $msg = null 
)

Add a rule from the valdiation

Parameters
string$typeValidation type
array$prmParameter for this rule
string$msgThe error message

Definition at line 44 of file valid.class.php.

◆ afterInit()

afterInit ( )
protectedinherited

Call just after the configuration initialisation

Definition at line 40 of file object.class.php.

◆ beforeInit()

beforeInit ( )
protectedinherited

Call just before the configuration initialisation

Definition at line 35 of file object.class.php.

◆ delRule()

delRule (   $type)

Delete a rule from the valdiation

Parameters
string$typeValidation type

Definition at line 67 of file valid.class.php.

◆ getAttr()

getAttr (   $name)
inherited

Get an attribute

Parameters
string$nameAttribute name
Returns
mixed|null The attribute or null if not set

Definition at line 48 of file object.class.php.

◆ getCfg()

getCfg ( )
inherited

Get the configuration object

Returns
config

Definition at line 67 of file object.class.php.

◆ getErrors()

getErrors ( )

Get all the errors for the last validation

Returns
array The errors, empty if no errors

Definition at line 375 of file valid.class.php.

◆ getMessage()

getMessage (   $name)
protected

Get a message for an error

Parameters
string$nameError name
Returns
string The message

Definition at line 356 of file valid.class.php.

◆ getRules()

getRules ( )

Get the validation rules array

Returns
array

Definition at line 76 of file valid.class.php.

◆ getValue()

getValue ( )

Get the value

Returns
mixed

Definition at line 24 of file valid.class.php.

◆ hasRule()

hasRule (   $type)

Indicates if a rule is set for the valid object;

Parameters
strong$typeValidation type
Returns
bool

Definition at line 58 of file valid.class.php.

◆ isAtLeastOneField()

isAtLeastOneField (   $val,
  $prm = null 
)

Check if all at least one of the paramtred fields is present

Parameters
mixed$valThe value to test against (not used)
array$prmAn array with the keys:
  • form form: The form where to retrieve the values
  • array fields: The fields names
Returns
bool True if valid

Definition at line 239 of file valid.class.php.

◆ isCallback()

isCallback (   $val,
  $prm = null 
)

Check if the value using a callback

Parameters
mixed$valThe value to test against
mixed$prmA valid PHP callback. This callback should true if valid or false if not or a string if a specific message should be used
Returns
bool True if valid

Definition at line 261 of file valid.class.php.

◆ isDbExists()

isDbExists (   $val,
array  $prm 
)

Check if the value exists in a database table

Parameters
mixed$valThe value to test against
array$prmThe parameter for the test with keys:
  • db_table|string: Table object or tablename (required)
  • string field: Fieldname to test against
Returns
bool True if valid

Definition at line 337 of file valid.class.php.

◆ isDbUnique()

isDbUnique (   $val,
array  $prm 
)

Check if the value is not present in a database table

Parameters
mixed$valThe value to test against
array$prmThe parameter for the test with keys:
  • mixed value: a value to ignore the test
  • db_table|string: Table object or tablename (required)
  • string field: Fieldname to test against
Returns
bool True if valid

Definition at line 312 of file valid.class.php.

◆ isDifferent()

isDifferent (   $val,
  $prm = null 
)

Check if the value is different. Strandard PHP test is done

Parameters
mixed$valThe value to test against
mixed$prmThe parameter for the test. Key 0 should be here and is the value to test against
Returns
bool True if valid

Definition at line 153 of file valid.class.php.

◆ isEmail()

isEmail (   $val,
  $prm = null 
)

Check if the value is an email address

Parameters
mixed$valThe value to test against
null$prmThe parameter for the test (not used here)
Returns
bool True if valid

Definition at line 294 of file valid.class.php.

◆ isEqual()

isEqual (   $val,
  $prm = null 
)

Check if the value is equal to another

Parameters
mixed$valThe value to test against
form_abstract | string$prmThe parameter for the test. If form_abstract is provided, the rawValue will be used for the test
Returns
bool True if valid

Definition at line 189 of file valid.class.php.

◆ isGroupedFields()

isGroupedFields (   $val,
  $prm = null 
)

Check if all parametred fields of a form are all eiher empty or all present

Parameters
mixed$valThe value to test against (not used)
array$prmAn array with the keys:
  • form form: The form where to retrieve the values
  • array fields: The grouped fields names
Returns
bool True if valid

Definition at line 214 of file valid.class.php.

◆ isIn()

isIn (   $val,
  $prm = null 
)

Check if the value is contained in an array

Parameters
mixed$valThe value to test against
array | string$prmThe parameter for the test Array to search in or string to test directly against
Returns
bool True if valid

Definition at line 168 of file valid.class.php.

◆ isInt()

isInt (   $val,
  $prm = null 
)

Check if the value is integer

Parameters
mixed$valThe value to test against
null$prmThe parameter for the test (not used here)
Returns
bool True if valid

Definition at line 138 of file valid.class.php.

◆ isNumeric()

isNumeric (   $val,
  $prm = null 
)

Check if the value is numeric

Parameters
mixed$valThe value to test against
null$prmThe parameter for the test (not used here)
Returns
bool True if valid

Definition at line 123 of file valid.class.php.

◆ isRequired()

isRequired (   $val,
  $prm = null 
)

Check if the value is here

Parameters
mixed$valThe value to test against
null$prmThe parameter for the test (not used here)
Returns
bool True if valid

Definition at line 108 of file valid.class.php.

◆ isUrl()

isUrl (   $val,
  $prm = null 
)

Check if the value is an URL (starting with http)

Parameters
mixed$valThe value to test against
null$prmThe parameter for the test (not used here)
Returns
bool True if valid

Definition at line 279 of file valid.class.php.

◆ isValid()

isValid ( )

Process to the validation

Returns
bool True if valid

Definition at line 85 of file valid.class.php.

◆ setAttr()

setAttr (   $name,
  $value 
)
inherited

Set an attribute

Parameters
string$nameAttribute name
mixed$valueAttribute value

Definition at line 58 of file object.class.php.

◆ setMessage()

setMessage (   $name,
  $msg 
)

Set an error message

Parameters
string$nameMessage keyname
string$msgThe message

Definition at line 366 of file valid.class.php.

◆ setValue()

setValue ( $value)

Set a new value reference

Parameters
mixed$valuethe new Value

Definition at line 33 of file valid.class.php.

Field Documentation

◆ $cfg

$cfg
protectedinherited

Definition at line 17 of file object.class.php.

◆ $errors

$errors = array()
protected

Definition at line 17 of file valid.class.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 15 2017 22:25:21 for nyroFwk by doxygen 1.8.13