PHP Class Controller_Validator_Basic, atk4

Inheritance: extends Controller_Validator_Abstract
ファイルを表示 Open project: atk4/atk4 Class Usage Examples

Public Methods

Method Description
init ( )
rule_after ( $a ) Checks any PHP datetime format: http://www.php.net/manual/en/datetime.formats.date.php.
rule_alpha ( $a ) Test for A-Za-z.
rule_alphanum ( $a ) Test for A-Za-z0-9.
rule_before ( $a ) Checks any PHP datetime format: http://www.php.net/manual/en/datetime.formats.date.php.
rule_between ( $a ) Inclusive range check.
rule_bool ( $a ) Validate for true|false|t|f|1|0|yes|no|y|n.
rule_card_from_date ( $a ) Validate a card "valid from" date.
rule_card_to_date ( $a ) Validate a card "expires end" date.
rule_class ( $a )
rule_credit_card ( $a ) Validate for credit card number.
rule_decimal ( $a )
rule_decimal_places ( $a ) Checks for a specific number of decimal places.
rule_email ( $a ) * \section Value Test Rules: Postal, Email & Credit Card
rule_eq ( $a )
rule_eqf ( $a )
rule_false ( $a ) Validate for false|f|0|no|n.
rule_gt ( $a )
rule_gte ( $a )
rule_in ( $a ) Checks that value is in the list provided.
rule_int ( $a )
rule_iso_datetime ( $a ) Validate ISO datetime in the format:.
rule_iso_time ( $a ) Validate for ISO time.
rule_len ( $a )
rule_lt ( $a )
rule_lte ( $a )
rule_not_in ( $a ) Checks that value is not in the list provided.
rule_number ( $a ) Checks for int or float.
rule_phone ( $a )
rule_regex ( $a ) Requires a regex pattern as the next rule in the chain.
rule_required ( $a ) * \section Value Test Rules: General
rule_to_add_slashes ( $a )
rule_to_alpha ( $a ) Strip to A-Za-z0-9.
rule_to_alpha_num ( $a )
rule_to_alpha_num_dash ( $a )
rule_to_alpha_num_dash_unicode ( $a ) Strip to unicode letter characters and 0-9, -, _.
rule_to_alpha_num_unicode ( $a ) Strip to unicode letter characters and 0-9.
rule_to_alpha_unicode ( $a ) Test for unicode letter characters.
rule_to_digits_and_single_spaces ( $a )
rule_to_float ( $a )
rule_to_int ( $a ) * \section Value Conversion Rules: Numeric
rule_to_iso_date ( $a ) * \section Value Conversion Rules: Date & Time
rule_to_lower ( $a )
rule_to_ltrim ( $a )
rule_to_name ( $name, $is_capitalise_prefix = false ) Useful for cleaning up input where you don't want to present an error to the user - eg a checkout where ease of use is more important than accuracy. Can save a lot of re-keying.
rule_to_number ( $a )
rule_to_quote_meta ( $a )
rule_to_rtrim ( $a )
rule_to_strip_extra_space ( $a ) Reduce sequential whitespaces to a single space.
rule_to_strip_nasties ( $a ) Strip out attack characters from names & addresses and other strings where they have no place.
rule_to_strip_slashes ( $a )
rule_to_strip_space ( $a ) Strip out all white space.
rule_to_strip_tags ( $a ) * \section Value Conversion Rules: Data Sanitization
rule_to_trim ( $a ) * \section Value Conversion Rules: String
rule_to_truncate ( $a ) Truncates, and adds '.
rule_to_truncate_custom ( $a ) Requires parameters: length, custom string to end of string.
rule_to_upper ( $a )
rule_to_upper_words ( $a )
rule_to_zip ( $a ) Normalizes, then validates.
rule_true ( $a ) Validate for true|t|1|yes|y.
rule_type ( $a )
rule_zip ( $a ) Checks for a 5 digit or extended US zip.
to_strip_regex ( $a ) Strips out the characters matched by the pattern in the argument.
validate_iso_date ( $a ) Validate for ISO date in format YYYY-MM-DD.

Protected Methods

Method Description
card_date_parser ( $a, $type ) Helper for validating card to and from dates.
prep_in_vals ( $a ) Explode and trim a comma-delmited list for the in and not_in rules.
strip_excess_whitespace ( $a ) Reduce sequential whitespaces to a single space.

Method Details

card_date_parser() protected method

Helper for validating card to and from dates.
protected card_date_parser ( $a, $type )

init() public method

public init ( )

prep_in_vals() protected method

Explode and trim a comma-delmited list for the in and not_in rules.
protected prep_in_vals ( $a )

rule_after() public method

Checks any PHP datetime format: http://www.php.net/manual/en/datetime.formats.date.php.
public rule_after ( $a )

rule_alpha() public method

Test for A-Za-z.
public rule_alpha ( $a )

rule_alphanum() public method

Test for A-Za-z0-9.
public rule_alphanum ( $a )

rule_before() public method

Checks any PHP datetime format: http://www.php.net/manual/en/datetime.formats.date.php.
public rule_before ( $a )

rule_between() public method

Overloaded: checks value for numbers, string-length for other values. Next 2 rules must specify the min and max
public rule_between ( $a )

rule_bool() public method

Normalizes to lower case
public rule_bool ( $a )

rule_card_from_date() public method

Validate a card "valid from" date.
public rule_card_from_date ( $a )

rule_card_to_date() public method

Validate a card "expires end" date.
public rule_card_to_date ( $a )

rule_class() public method

public rule_class ( $a )

rule_credit_card() public method

Uses the Luhn Mod 10 check
public rule_credit_card ( $a )

rule_decimal() public method

public rule_decimal ( $a )

rule_decimal_places() public method

Arg: int- number of places
public rule_decimal_places ( $a )

rule_email() public method

* \section Value Test Rules: Postal, Email & Credit Card
public rule_email ( $a )

rule_eq() public method

public rule_eq ( $a )

rule_eqf() public method

public rule_eqf ( $a )

rule_false() public method

Normalizes to lower case Useful for 'if' rules
public rule_false ( $a )

rule_gt() public method

public rule_gt ( $a )

rule_gte() public method

public rule_gte ( $a )

rule_in() public method

Syntax: |in|foo,bar,foobar.
public rule_in ( $a )

rule_int() public method

public rule_int ( $a )

rule_iso_datetime() public method

YYYY-MM-DD hh:mm:ss with optional microseconds
public rule_iso_datetime ( $a )

rule_iso_time() public method

Requires a complete hour:minute:second time with the optional ':' separators. Checks for hh:mm[[:ss][.**..] where * = microseconds Also checks for valid # of hours, mins, secs
public rule_iso_time ( $a )

rule_len() public method

public rule_len ( $a )

rule_lt() public method

public rule_lt ( $a )

rule_lte() public method

public rule_lte ( $a )

rule_not_in() public method

Syntax: |not_in|foo,bar,foobar.
public rule_not_in ( $a )

rule_number() public method

Checks for int or float.
public rule_number ( $a )

rule_phone() public method

public rule_phone ( $a )

rule_regex() public method

Please give your rule a custom error message.
public rule_regex ( $a )

rule_required() public method

* \section Value Test Rules: General
public rule_required ( $a )

rule_to_add_slashes() public method

public rule_to_add_slashes ( $a )

rule_to_alpha() public method

Strip to A-Za-z0-9.
public rule_to_alpha ( $a )

rule_to_alpha_num() public method

public rule_to_alpha_num ( $a )

rule_to_alpha_num_dash() public method

public rule_to_alpha_num_dash ( $a )

rule_to_alpha_num_dash_unicode() public method

Requires PCRE compiled with "--enable-unicode-properties". Most distros these days will offer this

rule_to_alpha_num_unicode() public method

Should work even is PCRE compiled without "--enable-unicode-properties".

rule_to_alpha_unicode() public method

Should work even is PCRE compiled without "--enable-unicode-properties".
public rule_to_alpha_unicode ( $a )

rule_to_digits_and_single_spaces() public method

rule_to_float() public method

public rule_to_float ( $a )

rule_to_int() public method

* \section Value Conversion Rules: Numeric
public rule_to_int ( $a )

rule_to_iso_date() public method

* \section Value Conversion Rules: Date & Time
public rule_to_iso_date ( $a )

rule_to_lower() public method

public rule_to_lower ( $a )

rule_to_ltrim() public method

public rule_to_ltrim ( $a )

rule_to_name() public method

Some libraries don't clean up names if already in mixed case. Experience shows this isn't very useful, as many users will type mAry, JOSepH etc. Can only be a best guess - but much better than nothing: has been in production for years without any negative customer feedback. Set $is_capitalise_prefix if you want prefixes in upper: Von Trapp vs von Trapp. You would do this to format a last name for use in salutations: Dear Mr Von Trapp Can handle full names, 1st only, middle only, last only. Cleans up extra whitespace.
public rule_to_name ( $name, $is_capitalise_prefix = false )

rule_to_number() public method

public rule_to_number ( $a )

rule_to_quote_meta() public method

public rule_to_quote_meta ( $a )

rule_to_rtrim() public method

public rule_to_rtrim ( $a )

rule_to_strip_extra_space() public method

Reduce sequential whitespaces to a single space.

rule_to_strip_nasties() public method

Strips: * ^ <> ? ! () | / \ [] + = % ; ~ `
public rule_to_strip_nasties ( $a )

rule_to_strip_slashes() public method

public rule_to_strip_slashes ( $a )

rule_to_strip_space() public method

Strip out all white space.
public rule_to_strip_space ( $a )

rule_to_strip_tags() public method

* \section Value Conversion Rules: Data Sanitization
public rule_to_strip_tags ( $a )

rule_to_trim() public method

* \section Value Conversion Rules: String
public rule_to_trim ( $a )

rule_to_truncate() public method

..' to end of string. Requires parameter 'length'
public rule_to_truncate ( $a )

rule_to_truncate_custom() public method

Requires parameters: length, custom string to end of string.
public rule_to_truncate_custom ( $a )

rule_to_upper() public method

public rule_to_upper ( $a )

rule_to_upper_words() public method

public rule_to_upper_words ( $a )

rule_to_zip() public method

Normalizes, then validates.
public rule_to_zip ( $a )

rule_true() public method

Normalizes to lower case Useful for 'if' rules
public rule_true ( $a )

rule_type() public method

public rule_type ( $a )

rule_zip() public method

Checks for a 5 digit or extended US zip.
public rule_zip ( $a )

strip_excess_whitespace() protected method

Reduce sequential whitespaces to a single space.
protected strip_excess_whitespace ( $a )

to_strip_regex() public method

The pattern should include the pattern delimiter, eg: my_pattern/
public to_strip_regex ( $a )

validate_iso_date() public method

Also checks for valid month and day values
public validate_iso_date ( $a )