Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2.  
  3. class User extends PropertyList {
  4.  
  5.     public function __construct()
  6.     {
  7.    
  8.         $this->addProperty('username')
  9.           ->setType('string')
  10.           ->setMinLength(4)
  11.           ->setMaxLength(20)
  12.           ->setRegularExpression('/^[a-zA-Z0-9][a-zA-Z0-9.-]+[a-zA-Z0-9]$/')
  13.         ;
  14.  
  15.         $this->addProperty('password')
  16.           ->setType('string')
  17.           ->setMinLength(8)
  18.           ->setMaxLength(30)
  19.           ->setFunctionSet(function($val){
  20.             return sha1($val);
  21.           })
  22.           ->setFunctionGet(function(){
  23.             return null;
  24.           })
  25.         ;
  26.    
  27.     }
  28.  
  29. }
  30.  
  31.  
  32. $usr = new User();
  33.  
  34. try {
  35.     $usr->username = 'blaa';
  36.     $usr->password = 'dasjdhlahqu97';
  37.     echo "successfully added username and password\n";
  38. } catch(Exception $e) {
  39.     echo "username or password not valid\n";
  40. }
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement