2017 © Pedro Peláez
 

elgg-plugin hypeprototypervalidators

hypePrototyper validation rules

image

hypejunction/hypeprototypervalidators

hypePrototyper validation rules

  • Wednesday, December 9, 2015
  • by hypeJunction
  • Repository
  • 2 Watchers
  • 0 Stars
  • 153 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

hypePrototyper Validators

Predefined Validators

type

Asserts that user input is expected to be of a certain type., (*1)

  • string
  • alnum - allows only alphanumeric characters and whitespaces
  • alpha - allows only alpha characters and whitespaces
  • int - allow only integer values
  • numeric - allows numeric values
  • date - allows date/time strings and objects
  • url - allows only valid URLs
  • email - allows only valid email addresses
    $field = array(
        'type' => 'text',
        'validation_rules' => array(
            'type' => 'alnum',
        ),
    );

min and max

Asserts that user input is between min and max values, (*2)

    $field = array(
        'type' => 'text',
        'validation_rules' => array(
            'type' => 'int',
            'min' => 10,
            'max' => 20,
        ),
    );

minlength and maxlength

Asserts that the length of user input is between min and max values, (*3)

    $field = array(
        'type' => 'password',
        'validation_rules' => array(
            'type' => 'string',
            'minlength' => 6,
            'maxlength' => 25,
        ),
    );

contains

Asserts that user input contains a predefined string, (*4)

    $field = array(
        'type' => 'text',
        'validation_rules' => array(
            'type' => 'string',
            'contains' => 'hello world',
        ),
    );

regex

Asserts that user input matches a regex pattern, (*5)

    $field = array(
        'type' => 'time',
        'validation_rules' => array(
            'type' => 'string',
            'regex' => '^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$',
        ),
    );

Custom Validators

You can define custom validation rules, using the following pattern:, (*6)


// Callback for validating user input elgg_register_plugin_hook_handler('validate:my_rule', 'prototyper', 'my_callback'); // Register the validation rule to make it available in hypePrototyperUI hypePrototyper()->config->registerValidationRule('my_rule');

Client-Side Validation

Partial client-side validation is available through Parsley.js. Do enable validation, add data-parsley-validate to your form attributes., (*7)


echo elgg_view_form('my_prototyped_form', array( 'enctype' => 'multipart/form-data', 'data-parsley-validate' => true, ), $vars);

The Versions

09/12 2015

5.x-dev

5.9999999.9999999.9999999-dev http://hypejunction.com

hypePrototyper validation rules

  Sources   Download

GPL-2.0

The Requires

 

by Ismayil Khayredinov

plugin forms validators elgg prototypes

02/09 2015

dev-dev

dev-dev http://hypejunction.com

hypePrototyper validation rules

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ismayil Khayredinov

plugin forms validators elgg prototypes

02/09 2015

4.2.2

4.2.2.0 http://hypejunction.com

hypePrototyper validation rules

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ismayil Khayredinov

plugin forms validators elgg prototypes

24/08 2015

4.2.1

4.2.1.0 http://hypejunction.com

hypePrototyper validation rules

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ismayil Khayredinov

plugin forms validators elgg prototypes

11/08 2015

4.2.0

4.2.0.0 http://hypejunction.com

hypePrototyper validation rules

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ismayil Khayredinov

plugin forms validators elgg prototypes

11/08 2015

dev-master

9999999-dev http://hypejunction.com

hypePrototyper validation rules

  Sources   Download

GPL-2.0

The Requires

 

The Development Requires

by Ismayil Khayredinov

plugin forms validators elgg prototypes