Fuelphp Series (iv)------Validate Verification

Source: Internet
Author: User
Tags uppercase letter

One, the available rules:

1, required cannot be null , false or empty string.;

2, required_with associated with a field, the associated field has a value, the field must have a value;

3, match_value two parameters: param1, to match the character; param2, whether strict (true is congruent, = = =);

4, match_pattern matching preg;

5, Match_field match field, such as re-enter the password confirmation (congruent = = =);

6, match_collection two parameters: param1, to match the array;param2, whether strict;

7, min_length Minimum length;

8, max_length maximum length;

9, Exact_length length is the specified length;

10, valid_date two parameters: param1, Time formate;param2, whether strict (default is true);

11, Valid_email single mailbox verification;

12, valid_emails multiple mailbox authentication, parameter is delimiter (default is commas);

13, Valid_url URL verification;

14, VALID_IP IP authentication, the parameter is ‘ipv4‘ or ‘ipv6‘ ;

15, Numeric_min digit minimum value (not the number as 0);

16, Numeric_max Digital maximum (not the number as 0);

17, Numeric_between two parameters: Min,max;

18, valid_string Verify string, parameter is array ();

String Validation rule:

FLAG DESCRIPTION
Alpha Letters
Uppercase Only uppercase letters are allowed
lowercase Only lowercase letters allowed
Specials Allow special characters
Numeric Digital
Spaces Space
Newlines Line break
Tabs TAB key
Dots Point
Commas Comma
Punctuation Allow dots, commas, exclamation points, question marks, colons, and half colons
Dashes Allow Middle horizontal, underline
Singlequotes Single quotation marks
Doublequotes Double quotes
Quotes Allow single quotes, double quotes
Forwardslashes Slash Slash
Backwardslashes Back slash
Slashes Allow slashes, backslashes
Brackets Brackets
Braces Curly Braces
Utf8 Adding UTF8 modifiers to regular expressions

Two, extensible authentication method, the method name begins with ' _validation_ ', for example:

//Prevent duplicate Additions     Public Static function_validation_unique ($val,$options)    {        List($table,$field) =Explode(‘.‘,$options); $result= Db::select (db::expr ("LOWER (\")$field\")"))        ->where ($field, ' = ', Str::lower ($val))        ->from ($table),execute (); return! ($result-Count() > 0); }    //determine if it is an uppercase letter     Public function_validation_is_upper ($val)    {        return $val===Strtoupper($val); }

* Get current Validation object, verify field

// gets the current validation object $active = validation::active ();
// get the current validation field $field = Validation::Active_field (); $field $active
// label of the current field $label $active:: Active_field ()->get_attribute (' label ');
// Current validation Settings error message Validation::active ()->set_message (' Unique ', ' the Field:label must is unique, But:value has already been used ');

Third, the verification method

  $val  = Validation::forge ();   $val ->add_field (' name ', ' name ', ' Required|unique '  //   $val ->add (' name ', ' name ')->add_rule (' Required ')->add_rule (' unique ') Span style= "color: #000000");   $val ->set_message (' Required ', ' you had to fill in Your:label ' 
// Get verified Information $val->validated (' username ');

Fuelphp Series (iv)------Validate Verification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.