- Added test coverance for invalid queries
[activemongo.git] / samples / references / User.php
blob9e3d3a93d411af72ba4924d79d8783c5a5bb5973
1 <?php
3 class User extends ActiveMongo
5 public $username;
6 public $password;
8 public $services;
10 function password_filter(&$value, $old_value)
12 if (strlen($value) < 5) {
13 throw new ActiveMongo_FilterException("Password is too short");
15 $value = sha1($value);
18 function after_update($document)
20 if (isset($GLOBALS['debug'])) {
21 var_dump(array(get_class($this) => $document));
25 function username_filter($value, $old_value)
27 if ($old_value!=null && $value != $old_value) {
28 throw new ActiveMongo_FilterException("The username can't be changed");
31 if (!preg_match("/[a-z][a-z0-9\-\_]+/", $value)) {
32 throw new ActiveMongo_FilterException("The username is not valid");
35 if (strlen($value) < 5) {
36 throw new ActiveMongo_FilterException("Username too short");
38 return TRUE;
41 function add_service(Service $obj)
43 $this->services[] = $obj;