]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add validation methods to classes
authorEvan Prodromou <evan@prodromou.name>
Tue, 20 May 2008 18:57:56 +0000 (14:57 -0400)
committerEvan Prodromou <evan@prodromou.name>
Tue, 20 May 2008 18:57:56 +0000 (14:57 -0400)
darcs-hash:20080520185756-84dde-290bc12cddfc1738a96385e95821d466eff11196.gz

classes/Avatar.php
classes/Notice.php
classes/Profile.php
classes/Remote_profile.php
classes/User.php
doc/README [new file with mode: 0644]
doc/TODO

index 2e0e1f3fb5ae2688e89833c6515d964d4d43e69e..57e0d2fa874da85015ab1899d1f2fb5de63975d5 100644 (file)
@@ -25,4 +25,16 @@ class Avatar extends DB_DataObject
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
+       
+       function validateMediatype() {
+               return Validate::string($this->mediatype, array('min_length' => 1, 'max_length' => 32));
+       }
+       
+       function validateFilename() {
+               return Validate::string($this->filename, array('min_length' => 1, 'max_length' => 255));
+       }
+       
+       function validateUrl() {
+               return Validate::uri($this->url, array('allowed_schemes' => array('http', 'https')));
+       }
 }
index 24c8133308fadfd2c0b1ba728266d5ac8ea066d2..3e6835ec90799472f05b6ff69cf19ad175cd7639 100644 (file)
@@ -52,4 +52,13 @@ class Notice extends DB_DataObject
                }
                return $this->profile;
        }
+       
+       function validateContent() {
+               return Validate::string($this->content, array('min_length' => 1, 'max_length' => 140));
+       }
+       
+       function validateUrl() {
+               return is_null($this->url) ||
+                 Validate::uri($this->url, array('allowed_schemes' => array('http', 'https')));
+       }
 }
index 686a7916303fb3491cc9a3457589b7bda6af5625..4119cd4113996c4013aac75fbbbb8dd8d3747ac7 100644 (file)
@@ -72,4 +72,33 @@ class Profile extends DB_DataObject
                        return NULL;
                }
        }
+       
+       function validateNickname() {
+               return Validate::string($this->nickname, array('min_length' => 1, 'max_length' => 64,
+                                                                                                          'format' => VALIDATE_ALPHA_LOWER . VALIDATE_NUM));
+       }
+       
+       function validateProfileurl() {
+               return Validate::uri($this->profileurl, array('allowed_schemes' => array('http', 'https')));
+       }
+       
+       function validateHomepage() {
+               return (is_null($this->homepage) ||
+                               Validate::uri($this->homepage, array('allowed_schemes' => array('http', 'https'))));
+       }
+               
+       function validateBio() {
+               return is_null($this->bio) || 
+                 Validate::string($this->bio, array('min_length' => 1, 'max_length' => 140));
+       }
+       
+       function validateLocation() {
+               return is_null($this->location) ||
+                 Validate::string($this->location, array('min_length' => 1, 'max_length' => 255));
+       }
+       
+       function validateFullname() {
+               return is_null($this->fullname) ||
+                 Validate::string($this->fullname, array('min_length' => 1, 'max_length' => 255));
+       }
 }
index 0aa727ad154629c4652813402aa0802271763b0f..f36ac5f0c02577b64b5ba125c85079bc58082055 100644 (file)
@@ -40,4 +40,9 @@ class Remote_profile extends DB_DataObject
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
+       
+       function validateUrl() {
+               return is_null($this->url) ||
+                 Validate::uri($this->url, array('allowed_schemes' => array('http', 'https')));
+       }
 }
index 8986053c5870243314f36dabf28ced7983c560e7..8effd856ab27b76b6d729ded9a85602a35eb21f5 100644 (file)
@@ -22,6 +22,7 @@ if (!defined('LACONICA')) { exit(1); }
  * Table Definition for user
  */
 require_once 'DB/DataObject.php';
+require_once 'Validate.php';
 
 class User extends DB_DataObject 
 {
@@ -59,4 +60,13 @@ class User extends DB_DataObject
                $sub->subscribed = $other->id;
                return $sub->find();
        }
+       
+       function validateEmail() {
+               return Validate::email($this->email, true);
+       }
+       
+       function validateNickname() {
+               return Validate::string($this->nickname, array('min_length' => 1, 'max_length' => 64,
+                                                                                                          'format' => VALIDATE_ALPHA_LOWER . VALIDATE_NUM));
+       }
 }
diff --git a/doc/README b/doc/README
new file mode 100644 (file)
index 0000000..546e432
--- /dev/null
@@ -0,0 +1,6 @@
+This package requires PHP 5.x and the following PHP Pear libraries:
+
+- DB_DataObject
+- Validate
+- XMLWriter
+
index b8bb2f708d913e9fee8e99ad4745b49fa68d6585..5105fa2178b7cf80e14df0cbf16bfac41b718d8d 100644 (file)
--- a/doc/TODO
+++ b/doc/TODO
 - site logo
 - instructions
 - deal with PHP quotes escaping
+- fix layout of textarea
+- make notices into "big links"
+- fix spacing on notices
+- limit entry in textarea to 140 chars
 - release 0.2
 - set Last-Modified
 - XML sitemap generation