PHP Classes

File: profils/primary_types.php

Recommend this page to a friend!
  Classes of SaphirAngel   Input validation   profils/primary_types.php   Download  
File: profils/primary_types.php
Role: Example script
Content type: text/plain
Description: Auxiliary script
Class: Input validation
Validate request values of different types
Author: By
Last change: Update of profils/primary_types.php
Date: 8 months ago
Size: 838 bytes
 

Contents

Class file image Download
<?php
/**
 * Created by JetBrains PhpStorm.
 * User: SaphirAngel
 * Date: 12/10/12
 * Time: 17:12
 * To change this template use File | Settings | File Templates.
 */

$primaryTypes = new Profil('primary_types');
$primaryTypes->check(['i', 'int'], NOT_EMPTY | NUMERIC, 'i');
$primaryTypes->check(['s', 'string'], NOT_NULL, 's');
$primaryTypes->check(['k', 'key'], NOT_EMPTY | NUMERIC, 'i')
            ->
advance(['k', 'key'], ['i_range' => [0, 60]], 0);
$primaryTypes->check(['login', 'username'], NOT_EMPTY, 's')
            ->
advance(['login', 'username'], ['regex' => ['^[A-Za-z0-9_-]*$']]);
$primaryTypes->check('phonenumber', 0)
            ->
advance('phonenumber', ['regex' => ['^(?:\+[0-9]{1,3}|0)(?:[0-9]{9})$']]);


$formTypes = new Profil('form_types');
$formTypes->check('submit', 0)
          ->
advance('submit', [], false);