Advertisement
fabi0

Untitled

May 13th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.98 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * To change this license header, choose License Headers in Project Properties.
  5.  * To change this template file, choose Tools | Templates
  6.  * and open the template in the editor.
  7.  */
  8.  
  9. /**
  10.  * Description of validate
  11.  *
  12.  * @author fabi0
  13.  */
  14. class validate {
  15.  
  16.     private $_errors = array();
  17.     private $_data = Null;
  18.  
  19.     public function setData($data, $data1 = null) {
  20.         $this->_data = $data;
  21.         return $this;
  22.     }
  23.  
  24.     public function min_length($lenght) {
  25.         if (mb_strlen($this->_data, "utf8") >= $lenght) {
  26.            
  27.         } else {
  28.             $this->_errors[] = "101";
  29.         }
  30.         return $this;
  31.     }
  32.  
  33.     public function max_length($lenght) {
  34.         if (mb_strlen($this->_data, "utf8") <= $lenght) {
  35.            
  36.         } else {
  37.             $this->_errors[] = "102";
  38.         }
  39.  
  40.         return $this;
  41.     }
  42.  
  43.     public function string_length($min, $max) {
  44.         if (self::min_length($data, $min) && self::max_length($data, $max)) {
  45.            
  46.         } else {
  47.             $this->_errors[] = "103";
  48.         }
  49.     }
  50.  
  51.     public function range($min, $max) {
  52.         if ($data >= $min && $data <= $max) {
  53.            
  54.         } else {
  55.             $this->_errors[] = "104";
  56.         }
  57.         return $this;
  58.     }
  59.  
  60.     public function match($value1, $value2) {
  61.         if ($value1 === $value2) {
  62.            
  63.         } else {
  64.             $this->_errors[] = "105";
  65.         }
  66.  
  67.         return $this;
  68.     }
  69.  
  70.     public function email() {
  71.         if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
  72.            
  73.         } else {
  74.             $this->_errors[] = "106";
  75.         }
  76.         return $this;
  77.     }
  78.  
  79.     public function required() {
  80.         if ($this->_data == '') {
  81.             $this->_errors[] = "107";
  82.         }
  83.         return $this;
  84.     }
  85.  
  86.     public function getErrors() {
  87.         return $this->_errors;
  88.     }
  89.  
  90.     public function clearErrors() {
  91.         $this->_errors = NULL;
  92.     }
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement