Beispiel #1
0
 /**
  * 
  * @assert("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1") === true
  * @assert("rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1") === true
  * @assert("rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2") === true
  * @assert("rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2") === true
  * @assert("4k3/8/8/8/8/8/4P3/4K3 w - - 5 39") === true
  * @assert("Prq1823Br b kqKQ 1 1 1") === false
  * @assert(2) === false
  * @assert("a") === false
  * @assert(NULL) === false
  * 
  * @param mixed $data
  * @return boolean returns if a data is valid
  */
 public function validate($data)
 {
     if (!parent::validate($data)) {
         return false;
     }
     return preg_match_all("/^" . self::validPattern() . "\$/", $data) === 1;
 }
Beispiel #2
0
 /**
  * Validation rules:
  * "...(Wherever a comma appears, the very next character
  * should be a space..."
  * Tests based on description:
  * @assert("Tal, Mikhail N.") === true
  * @assert("van der Wiel, Johan") === true
  * @assert("Acme Pawngrabber v.3.2") === true
  * @assert("?") === true
  * Basic path tests:
  * @assert (NULL) === false
  * @assert ("ab") === true
  * @assert (", ") === true
  * @assert (",a") === false
  * @assert ("a") === true
  * @param string $data
  * @return bool true if data is valid and false if not.
  */
 public function validate($data)
 {
     if (!parent::validate($data)) {
         return false;
     }
     while (strlen($data) >= 2) {
         if ($data[0] == ',' && $data[1] != ' ') {
             return false;
         }
         $previousLength = strlen($data);
         $data = strstr($data, ',');
         if (strlen($data) == $previousLength) {
             return true;
         }
     }
     return true;
 }
Beispiel #3
0
 /**
  * @assert ('0-1') === true
  * @assert ('1-0') === true
  * @assert ('1/2-1/2') === true
  * @assert ('*') === true
  * @assert ('O-1') === false
  * @assert ('1-O') === false
  * @assert ('0.5-0.5') === false
  * @assert ('?') === false
  * @assert ('0-10-1') === false
  * @assert ('0-11-0') === false
  * @assert ('1-00-1') === false
  * @assert ('1-01-0') === false
  * @assert ('1/2-1/21/2-1/2') === false
  * @assert ('**') === false
  * @assert ('1/2-1/2*') === false
  * @assert ('0-1*') === false
  * @param string $data
  * @return boolean
  */
 public function validate($data)
 {
     return parent::validate($data) && (bool) preg_match("/^" . self::validPattern() . "\$/", $data);
 }
Beispiel #4
0
 /**
  * 
  * @param Tag $tag
  */
 public function addTag($tag)
 {
     if ($tag instanceof Tag) {
         $this->tags[$tag->getName()] = $tag;
     }
 }