Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • areyouahuman
      • auth
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
        • default
      • exchange
        • rates
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • quickbooks
            • invoice
      • json
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • recaptcha
      • reports
        • aging
          • invoices
        • custom
          • report
        • invoice
          • creation
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • form
      • html
      • javascript
      • xml
    • lib
  • None
  • PHP

Classes

  • Input

Class Input

Supplies methods useful in verifying and formatting input data. Provides a number of methods to verify whether the input data is formatted correctly. Supports validating both scalar and array data.

Package: minPHP\components\input
Located at components/input/input.php

Methods summary

public static
# isEmail( string $str, boolean $check_record = true )

Checks if the given string is a valid email address

Checks if the given string is a valid email address

Parameters

$str
string
$str The string to test
$check_record
boolean
$check_record True to check DNS/MX record

Retrun

boolean True if the email is valid, false otherwise
public static boolean
# isEmpty( string $str )

Checks if the given string is empty or otherwise not set

Checks if the given string is empty or otherwise not set

Parameters

$str
string
$str The string to test

Returns

boolean
True if the string is empty or not set, false otherwise
public static boolean
# isPassword( string $str, integer $min_length = 6, string $type = "any", string $custom_regex = null )

Tests whether the given string meets the requirements to be considered a password

Tests whether the given string meets the requirements to be considered a password

Parameters

$str
string
$str The string to test
$min_length
integer
$min_length The minimum length of the string
$type
string
$type Types include "any", "any_no_space", "alpha_num", "alpha", "num", and "custom"
$custom_regex
string
$custom_regex Used when $type is set to "custom". Does not use $min_length, any length requirement must be included in the regex

Returns

boolean
True if it meets the given requirements, false otherwise
public static boolean
# isDate( string $str, mixed $min = null, mixed $max = null )

Tests whether the given string is considered a valid date suitable to strtotime()

Tests whether the given string is considered a valid date suitable to strtotime()

Parameters

$str
string
$str The string to test
$min
mixed
$min The minimum acceptable date (string) or unix time stamp (int)
$max
mixed
$min The maximum acceptable date (string) or unix time stamp (int)

Returns

boolean
True if $str is a valid date, false otherwise
public static boolean
# matches( string $str, string $regex )

Tests wether the given string satisfies the given regular expression

Tests wether the given string satisfies the given regular expression

Parameters

$str
string
$str The string to test
$regex
string
$regex The regular expression to satisfy

Returns

boolean
True when the string passes the regex, false otherwise
public static boolean
# compares( mixed $a, string $op, mixed $b )

Tests how the given values compare

Tests how the given values compare

Parameters

$a
mixed
$a The value to compare
$op
string
$op The comparison operator: >, <, >=, <=, ==, ===, !=, !==
$b
mixed
$b The value to compare against

Returns

boolean
True if $a validates $op against $b, false otherwise

Throws

Exception
Thrown when an unrecognized operator, $op, is given
public static boolean
# between( mixed $val, mixed $min, mixed $max, boolean $inclusive = true )

Tests that $val is between $min and $max

Tests that $val is between $min and $max

Parameters

$val
mixed
$val The value to compare
$min
mixed
$min The lower value to compare against
$max
mixed
$max The higher value to compare against
$inclusive
boolean
$inclusive Set to false if $val must be strictly between $min and $max

Returns

boolean
True if $val is between $min and $max, false otherwise
public static boolean
# minLength( string $str, integer $length )

Test whether $str is at least $length bytes

Test whether $str is at least $length bytes

Parameters

$str
string
$str The string to check
$length
integer
$length The number of bytes required in $str

Returns

boolean
True if $str is at least $length bytes
public static boolean
# maxLength( string $str, integer $length )

Test whether $str is no more than $length bytes

Test whether $str is no more than $length bytes

Parameters

$str
string
$str The string to check
$length
integer
$length The number of bytes allowed in $str

Returns

boolean
True if $str is no more than $length bytes
public static boolean
# betweenLength( string $str, integer $min_length, integer $max_length )

Test whether $str is between $min_length and $max_length

Test whether $str is between $min_length and $max_length

Parameters

$str
string
$str The string to check
$min_length
integer
$min_length The number of bytes required in $str
$max_length
integer
$max_length The number of bytes allowed in $str

Returns

boolean
True if $str is between $min_length and $max_length
public
# setRules( array $rules )

Set rules, overriding any existing rules set and empting any existing errors

Set rules, overriding any existing rules set and empting any existing errors

Parameters

$rules
array
$rules A multi-deminsional array, where the 1st dimension is the index value of the data given to Input::validates()

See

Input::validates()
public
# processValidation( mixed & $value, string $key, array $var, integer $max_depth = null, integer $cur_depth = 0, array $path = array() )

Invokes Input::validateRule() to process the rule against the given value. This method formatted for use by array_walk_recusrive to process elements recusively.

Invokes Input::validateRule() to process the rule against the given value. This method formatted for use by array_walk_recusrive to process elements recusively.

Parameters

$value
mixed
$value The value to evaluate
$key
string
$key The most immediate key to the given value
$var
array
$var An array containing the full string index of the rule to evaluate ('index') and the complete rule ('rule')
$max_depth
integer
$max_depth The maximum depth to travel
$cur_depth
integer
$cur_depth The current depth traveled
$path
array
$path A list of all array indexes encountered
public boolean
# validates( array & $data )

Validates all set rules using the given data, sets any error messages to Input::$errors Each ruleset attached to a field can have the following indices: rule, message, negate, last, final, pre_format, post_format

Validates all set rules using the given data, sets any error messages to Input::$errors Each ruleset attached to a field can have the following indices: rule, message, negate, last, final, pre_format, post_format

pre_format and post_format accept a typical PHP callback parameter, post_format will only be called if the rule passes validation

Parameters

$data
array
$data An array of data such as POST

Returns

boolean
true if all rules pass, false if any rule is broken

See

Input::errors()
public
# setErrors( array $errors )

Sets the given errors into the object, overriding existing errors (if any)

Sets the given errors into the object, overriding existing errors (if any)

Parameters

$errors
array
$errors An array of errors as returned by Input::errors()

See

Input::errors()
public mixed
# errors( )

Return all errors

Return all errors

Returns

mixed
An array of error messages indexed as their field name, boolean false if no errors set

Magic methods summary

Blesta API documentation generated by ApiGen 2.8.0