PHP Class Pommo_Validate, poMMo

This file is part of poMMo (http://www.pommo.org) poMMo is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or any later version. poMMo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with program; see the file docs/LICENSE. If not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Exibir arquivo Open project: soonick/poMMo Class Usage Examples

Public Methods

Method Description
addData ( string $name, string $type, $isEmptyAllowed, string $regex = null ) : void addData Adds Data to the array to be checked
addPasswordMatch ( $name1, $name2 ) : void addPasswordMatch Adds Data to the password match array to be checked
checkData ( ) : boolean checkData Runs the checks on the data fields and password matches
getErrors ( ) : array getErrors Returns what the validation errors were
setPost ( array $post ) : void setPost Recieves the incoming post into the array
subscriberData ( array &$in, $p = [] ) : boolean subscriberData Validates supplied subscriber data against fields

Private Methods

Method Description
validateDate ( $date ) : boolean validateDate Validates a date value
validateDateTime ( $date ) : boolean validateDateTime Validates a datetime value
validateEmail ( $email ) : boolean validateEmail Validates an E-mail address
validateTime ( $time ) : boolean validateTime Validates a time value for mysql
validateUrl ( $url ) : boolean validateUrl Validates an URL. This validation is part of smarty_validate plugin.
validatematchRegex ( $regex, $string ) : boolean validatematchRegex Validates that a string matches a regex

Method Details

addData() public method

@param string $name - Name of the input type (ie ID='name')
public addData ( string $name, string $type, $isEmptyAllowed, string $regex = null ) : void
$name string
$type string - Type to check. Valid Values Email date dateTime Time Url matchRegex Other (ie if you just want an empty check)
$regex string - if matchRegex was choosen in $type, then this is the regex that is going to be checked @return void
return void

addPasswordMatch() public method

@param string $name - Name of the input type (ie ID='name') string $name2 - Name of the 2nd input type
public addPasswordMatch ( $name1, $name2 ) : void
return void

checkData() public method

@param void
public checkData ( ) : boolean
return boolean True if NO errors

getErrors() public method

@param void
public getErrors ( ) : array
return array Array containing all error messages

setPost() public method

@param array $post - Incoming post
public setPost ( array $post ) : void
$post array
return void

subscriberData() public static method

@param array $in - The subscriber Data array $p - A parameter array with values as follows :- boolean prune - if true, prune the data array (passed by reference) to only recognized/checked fields boolean ignore - if true, invalid fields will be pruned from $in array -- no error thrown boolean ignoreInactive - if true, invalid inactive fields will be pruned from $in array - no error thrown boolean active - if true, only check data against active fields. Typically true if subscribing via form, false if admin importing. boolean skipReq - if true, skip the required check AND empty fields. boolean log - if true, log invalid fields as error. Typically true if subscribing via form, false if admin importing.
public static subscriberData ( array &$in, $p = [] ) : boolean
$in array
return boolean validation status NOTE: has the MAGIC FUNCTIONALITY of converting date field input to a UNIX TIMESTAMP. This is necessary for quick SQL comparisson of dates, etc. NOTE: has the MAGIC FUNCTINALITY of changing "true"/"false" to checkbox "on"/off equivelent NOTE: has the MAGIC FUNCTIONALITY of trimming leading and trailing whitepace NOTE: has the MAGIC FUNCTIONALITY of shortening value to 60 characters (or 255 if a comment type) TODO -> should fields be passed by reference? e.g. are they usually already available when subscriberData() is called?