Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User extends PropertyList {
- public function __construct()
- {
- $this->addProperty('username')
- ->setType('string')
- ->setMinLength(4)
- ->setMaxLength(20)
- ->setRegularExpression('/^[a-zA-Z0-9][a-zA-Z0-9.-]+[a-zA-Z0-9]$/')
- ;
- $this->addProperty('password')
- ->setType('string')
- ->setMinLength(8)
- ->setMaxLength(30)
- ->setFunctionSet(function($val){
- return sha1($val);
- })
- ->setFunctionGet(function(){
- return null;
- })
- ;
- }
- }
- $usr = new User();
- try {
- $usr->username = 'blaa';
- $usr->password = 'dasjdhlahqu97';
- echo "successfully added username and password\n";
- } catch(Exception $e) {
- echo "username or password not valid\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement