diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-11-04 21:33:05 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-11-04 21:33:05 -0500 |
commit | 135b921db75da5995eab7e36393ecd4d2b0bc66f (patch) | |
tree | 46efc60fcf1f9d5c57ab1fb9418c2acfbda0698a /vendor/SimpleValidator/Validators | |
parent | 850645dd6b22f5b495d1680e0b49540e0ebf9bd3 (diff) |
Switch to composer
Diffstat (limited to 'vendor/SimpleValidator/Validators')
-rw-r--r-- | vendor/SimpleValidator/Validators/Alpha.php | 33 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/AlphaNumeric.php | 33 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Date.php | 48 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Email.php | 81 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Equals.php | 43 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/GreaterThan.php | 36 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Integer.php | 42 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Ip.php | 33 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Length.php | 48 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/MacAddress.php | 37 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/MaxLength.php | 46 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/MinLength.php | 46 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Numeric.php | 33 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Range.php | 51 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Required.php | 30 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Unique.php | 78 | ||||
-rw-r--r-- | vendor/SimpleValidator/Validators/Version.php | 32 |
17 files changed, 0 insertions, 750 deletions
diff --git a/vendor/SimpleValidator/Validators/Alpha.php b/vendor/SimpleValidator/Validators/Alpha.php deleted file mode 100644 index b00b819b..00000000 --- a/vendor/SimpleValidator/Validators/Alpha.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Alpha extends Base -{ - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - if (! ctype_alpha($data[$this->field])) { - - return false; - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/AlphaNumeric.php b/vendor/SimpleValidator/Validators/AlphaNumeric.php deleted file mode 100644 index e1762d67..00000000 --- a/vendor/SimpleValidator/Validators/AlphaNumeric.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class AlphaNumeric extends Base -{ - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - if (! ctype_alnum($data[$this->field])) { - - return false; - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Date.php b/vendor/SimpleValidator/Validators/Date.php deleted file mode 100644 index 54c949b0..00000000 --- a/vendor/SimpleValidator/Validators/Date.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; -use \DateTime; - -class Date extends Base -{ - private $formats = array(); - - public function __construct($field, $error_message, array $formats) - { - parent::__construct($field, $error_message); - $this->formats = $formats; - } - - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - foreach ($this->formats as $format) { - if ($this->isValidDate($data[$this->field], $format) === true) { - return true; - } - } - - return false; - } - - return true; - } - - public function isValidDate($value, $format) - { - $date = DateTime::createFromFormat($format, $value); - - if ($date !== false) { - $errors = DateTime::getLastErrors(); - if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) { - $timestamp = $date->getTimestamp(); - return $timestamp > 0 ? true : false; - } - } - - return false; - } -} diff --git a/vendor/SimpleValidator/Validators/Email.php b/vendor/SimpleValidator/Validators/Email.php deleted file mode 100644 index e4e3d5d6..00000000 --- a/vendor/SimpleValidator/Validators/Email.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Email extends Base -{ - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - // I use the same validation method as Firefox - // http://hg.mozilla.org/mozilla-central/file/cf5da681d577/content/html/content/src/nsHTMLInputElement.cpp#l3967 - - $value = $data[$this->field]; - $length = strlen($value); - - // If the email address begins with a '@' or ends with a '.', - // we know it's invalid. - if ($value[0] === '@' || $value[$length - 1] === '.') { - - return false; - } - - // Check the username - for ($i = 0; $i < $length && $value[$i] !== '@'; ++$i) { - - $c = $value[$i]; - - if (! (ctype_alnum($c) || $c === '.' || $c === '!' || $c === '#' || $c === '$' || - $c === '%' || $c === '&' || $c === '\'' || $c === '*' || $c === '+' || - $c === '-' || $c === '/' || $c === '=' || $c === '?' || $c === '^' || - $c === '_' || $c === '`' || $c === '{' || $c === '|' || $c === '}' || - $c === '~')) { - - return false; - } - } - - // There is no domain name (or it's one-character long), - // that's not a valid email address. - if (++$i >= $length) return false; - if (($i + 1) === $length) return false; - - // The domain name can't begin with a dot. - if ($value[$i] === '.') return false; - - // Parsing the domain name. - for (; $i < $length; ++$i) { - - $c = $value[$i]; - - if ($c === '.') { - - // A dot can't follow a dot. - if ($value[$i - 1] === '.') return false; - } - elseif (! (ctype_alnum($c) || $c === '-')) { - - // The domain characters have to be in this list to be valid. - return false; - } - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Equals.php b/vendor/SimpleValidator/Validators/Equals.php deleted file mode 100644 index 91f34e4b..00000000 --- a/vendor/SimpleValidator/Validators/Equals.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Equals extends Base -{ - private $field2; - - - public function __construct($field1, $field2, $error_message) - { - parent::__construct($field1, $error_message); - - $this->field2 = $field2; - } - - - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - if (! isset($data[$this->field2])) return false; - - return $data[$this->field] === $data[$this->field2]; - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/GreaterThan.php b/vendor/SimpleValidator/Validators/GreaterThan.php deleted file mode 100644 index e038cb61..00000000 --- a/vendor/SimpleValidator/Validators/GreaterThan.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -class GreaterThan extends Base -{ - private $min; - - - public function __construct($field, $error_message, $min) - { - parent::__construct($field, $error_message); - $this->min = $min; - } - - - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - return $data[$this->field] > $this->min; - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Integer.php b/vendor/SimpleValidator/Validators/Integer.php deleted file mode 100644 index 150558a3..00000000 --- a/vendor/SimpleValidator/Validators/Integer.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Integer extends Base -{ - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - if (is_string($data[$this->field])) { - - if ($data[$this->field][0] === '-') { - - return ctype_digit(substr($data[$this->field], 1)); - } - - return ctype_digit($data[$this->field]); - } - else { - - return is_int($data[$this->field]); - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Ip.php b/vendor/SimpleValidator/Validators/Ip.php deleted file mode 100644 index 48afe569..00000000 --- a/vendor/SimpleValidator/Validators/Ip.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Ip extends Base -{ - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - if (! filter_var($data[$this->field], FILTER_VALIDATE_IP)) { - - return false; - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Length.php b/vendor/SimpleValidator/Validators/Length.php deleted file mode 100644 index 36e50b37..00000000 --- a/vendor/SimpleValidator/Validators/Length.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Length extends Base -{ - private $min; - private $max; - - - public function __construct($field, $error_message, $min, $max) - { - parent::__construct($field, $error_message); - - $this->min = $min; - $this->max = $max; - } - - - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - $length = mb_strlen($data[$this->field], 'UTF-8'); - - if ($length < $this->min || $length > $this->max) { - - return false; - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/MacAddress.php b/vendor/SimpleValidator/Validators/MacAddress.php deleted file mode 100644 index d9348417..00000000 --- a/vendor/SimpleValidator/Validators/MacAddress.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class MacAddress extends Base -{ - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - $groups = explode(':', $data[$this->field]); - - if (count($groups) !== 6) return false; - - foreach ($groups as $group) { - - if (! ctype_xdigit($group)) return false; - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/MaxLength.php b/vendor/SimpleValidator/Validators/MaxLength.php deleted file mode 100644 index d8e032b0..00000000 --- a/vendor/SimpleValidator/Validators/MaxLength.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class MaxLength extends Base -{ - private $max; - - - public function __construct($field, $error_message, $max) - { - parent::__construct($field, $error_message); - - $this->max = $max; - } - - - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - $length = mb_strlen($data[$this->field], 'UTF-8'); - - if ($length > $this->max) { - - return false; - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/MinLength.php b/vendor/SimpleValidator/Validators/MinLength.php deleted file mode 100644 index 4b7f7d24..00000000 --- a/vendor/SimpleValidator/Validators/MinLength.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class MinLength extends Base -{ - private $min; - - - public function __construct($field, $error_message, $min) - { - parent::__construct($field, $error_message); - - $this->min = $min; - } - - - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - $length = mb_strlen($data[$this->field], 'UTF-8'); - - if ($length < $this->min) { - - return false; - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Numeric.php b/vendor/SimpleValidator/Validators/Numeric.php deleted file mode 100644 index a958df1a..00000000 --- a/vendor/SimpleValidator/Validators/Numeric.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Numeric extends Base -{ - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - if (! is_numeric($data[$this->field])) { - - return false; - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Range.php b/vendor/SimpleValidator/Validators/Range.php deleted file mode 100644 index 1d71b926..00000000 --- a/vendor/SimpleValidator/Validators/Range.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Range extends Base -{ - private $min; - private $max; - - - public function __construct($field, $error_message, $min, $max) - { - parent::__construct($field, $error_message); - - $this->min = $min; - $this->max = $max; - } - - - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - if (! is_numeric($data[$this->field])) { - - return false; - } - - if ($data[$this->field] < $this->min || $data[$this->field] > $this->max) { - - return false; - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Required.php b/vendor/SimpleValidator/Validators/Required.php deleted file mode 100644 index e7ef2714..00000000 --- a/vendor/SimpleValidator/Validators/Required.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Required extends Base -{ - public function execute(array $data) - { - if (! isset($data[$this->field]) || $data[$this->field] === '') { - - return false; - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Unique.php b/vendor/SimpleValidator/Validators/Unique.php deleted file mode 100644 index c20dbe11..00000000 --- a/vendor/SimpleValidator/Validators/Unique.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - */ -class Unique extends Base -{ - private $pdo; - private $primary_key; - private $table; - - - public function __construct($field, $error_message, \PDO $pdo, $table, $primary_key = 'id') - { - parent::__construct($field, $error_message); - - $this->pdo = $pdo; - $this->primary_key = $primary_key; - $this->table = $table; - } - - - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - if (! isset($data[$this->primary_key])) { - - $rq = $this->pdo->prepare('SELECT COUNT(*) FROM '.$this->table.' WHERE '.$this->field.'=?'); - - $rq->execute(array( - $data[$this->field] - )); - - $result = $rq->fetch(\PDO::FETCH_NUM); - - if (isset($result[0]) && $result[0] === '1') { - - return false; - } - } - else { - - $rq = $this->pdo->prepare( - 'SELECT COUNT(*) FROM '.$this->table.' - WHERE '.$this->field.'=? AND '.$this->primary_key.' != ?' - ); - - $rq->execute(array( - $data[$this->field], - $data[$this->primary_key] - )); - - $result = $rq->fetch(\PDO::FETCH_NUM); - - if (isset($result[0]) && $result[0] === '1') { - - return false; - } - } - } - - return true; - } -}
\ No newline at end of file diff --git a/vendor/SimpleValidator/Validators/Version.php b/vendor/SimpleValidator/Validators/Version.php deleted file mode 100644 index 273a28a5..00000000 --- a/vendor/SimpleValidator/Validators/Version.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -/* - * This file is part of Simple Validator. - * - * (c) Frédéric Guillot <contact@fredericguillot.com> - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace SimpleValidator\Validators; - -use SimpleValidator\Base; - -/** - * @author Frédéric Guillot <contact@fredericguillot.com> - * @link http://semver.org/ - */ -class Version extends Base -{ - public function execute(array $data) - { - if (isset($data[$this->field]) && $data[$this->field] !== '') { - - $pattern = '/^[0-9]+\.[0-9]+\.[0-9]+([+-][^+-][0-9A-Za-z-.]*)?$/'; - return (bool) preg_match($pattern, $data[$this->field]); - } - - return true; - } -}
\ No newline at end of file |