From a4642d17e0e1ea018b128efdcc3db281461458b1 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 4 Apr 2018 15:21:13 -0700 Subject: Move custom libs to the source tree --- vendor/fguillot/simple-validator/LICENSE | 21 ------- .../src/SimpleValidator/Validator.php | 44 -------------- .../src/SimpleValidator/Validators/Alpha.php | 15 ----- .../SimpleValidator/Validators/AlphaNumeric.php | 15 ----- .../src/SimpleValidator/Validators/Base.php | 37 ------------ .../src/SimpleValidator/Validators/Date.php | 45 --------------- .../src/SimpleValidator/Validators/Email.php | 67 ---------------------- .../src/SimpleValidator/Validators/Equals.php | 27 --------- .../src/SimpleValidator/Validators/Exists.php | 38 ------------ .../src/SimpleValidator/Validators/GreaterThan.php | 23 -------- .../src/SimpleValidator/Validators/InArray.php | 23 -------- .../src/SimpleValidator/Validators/Integer.php | 25 -------- .../src/SimpleValidator/Validators/Ip.php | 15 ----- .../src/SimpleValidator/Validators/Length.php | 26 --------- .../src/SimpleValidator/Validators/MaxLength.php | 24 -------- .../src/SimpleValidator/Validators/MinLength.php | 24 -------- .../src/SimpleValidator/Validators/NotEmpty.php | 15 ----- .../src/SimpleValidator/Validators/NotEquals.php | 28 --------- .../src/SimpleValidator/Validators/NotInArray.php | 15 ----- .../src/SimpleValidator/Validators/Numeric.php | 15 ----- .../src/SimpleValidator/Validators/Range.php | 33 ----------- .../src/SimpleValidator/Validators/Required.php | 11 ---- .../src/SimpleValidator/Validators/Unique.php | 48 ---------------- 23 files changed, 634 deletions(-) delete mode 100644 vendor/fguillot/simple-validator/LICENSE delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validator.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Alpha.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/AlphaNumeric.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Base.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Date.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Email.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Equals.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Exists.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/GreaterThan.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/InArray.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Integer.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Ip.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Length.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MaxLength.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MinLength.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEmpty.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEquals.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotInArray.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Numeric.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Range.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Required.php delete mode 100644 vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Unique.php (limited to 'vendor/fguillot/simple-validator') diff --git a/vendor/fguillot/simple-validator/LICENSE b/vendor/fguillot/simple-validator/LICENSE deleted file mode 100644 index 6a362bc1..00000000 --- a/vendor/fguillot/simple-validator/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Frederic Guillot - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validator.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validator.php deleted file mode 100644 index 30015dc6..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validator.php +++ /dev/null @@ -1,44 +0,0 @@ -data = $data; - $this->validators = $validators; - } - - public function execute() - { - $result = true; - - foreach ($this->validators as $validator) { - if (! $validator->execute($this->data)) { - $this->addError($validator->getField(), $validator->getErrorMessage()); - $result = false; - } - } - - return $result; - } - - public function addError($field, $message) - { - if (! isset($this->errors[$field])) { - $this->errors[$field] = array(); - } - - $this->errors[$field][] = $message; - } - - public function getErrors() - { - return $this->errors; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Alpha.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Alpha.php deleted file mode 100644 index c29ba481..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Alpha.php +++ /dev/null @@ -1,15 +0,0 @@ -isFieldNotEmpty($data)) { - return ctype_alpha($data[$this->field]); - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/AlphaNumeric.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/AlphaNumeric.php deleted file mode 100644 index 8d5000b4..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/AlphaNumeric.php +++ /dev/null @@ -1,15 +0,0 @@ -isFieldNotEmpty($data)) { - return ctype_alnum($data[$this->field]); - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Base.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Base.php deleted file mode 100644 index 8157ae50..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Base.php +++ /dev/null @@ -1,37 +0,0 @@ -field = $field; - $this->error_message = $error_message; - } - - public function getErrorMessage() - { - return $this->error_message; - } - - public function getField() - { - if (is_array($this->field)) { - return $this->field[0]; - } - - return $this->field; - } - - public function isFieldNotEmpty(array $data) - { - return isset($data[$this->field]) && $data[$this->field] !== ''; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Date.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Date.php deleted file mode 100644 index 4ec4b7fd..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Date.php +++ /dev/null @@ -1,45 +0,0 @@ -formats = $formats; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - foreach ($this->formats as $format) { - if ($this->isValidDate($data[$this->field], $format)) { - 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) { - return $date->getTimestamp() > 0; - } - } - - return false; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Email.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Email.php deleted file mode 100644 index f3977042..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Email.php +++ /dev/null @@ -1,67 +0,0 @@ -isFieldNotEmpty($data)) { - - // 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; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Equals.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Equals.php deleted file mode 100644 index 6b69dd80..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Equals.php +++ /dev/null @@ -1,27 +0,0 @@ -field2 = $field2; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - if (! isset($data[$this->field2])) { - return false; - } - - return $data[$this->field] === $data[$this->field2]; - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Exists.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Exists.php deleted file mode 100644 index 1998e673..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Exists.php +++ /dev/null @@ -1,38 +0,0 @@ -pdo = $pdo; - $this->table = $table; - $this->key = $key; - } - - - public function execute(array $data) - { - if (! $this->isFieldNotEmpty($data)) { - return true; - } - - if ($this->key === '') { - $this->key = $this->field; - } - - $rq = $this->pdo->prepare('SELECT 1 FROM '.$this->table.' WHERE '.$this->key.'=?'); - $rq->execute(array($data[$this->field])); - - return $rq->fetchColumn() == 1; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/GreaterThan.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/GreaterThan.php deleted file mode 100644 index 6e560319..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/GreaterThan.php +++ /dev/null @@ -1,23 +0,0 @@ -min = $min; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - return $data[$this->field] > $this->min; - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/InArray.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/InArray.php deleted file mode 100644 index f2f8c134..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/InArray.php +++ /dev/null @@ -1,23 +0,0 @@ -array = $array; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - return in_array($data[$this->field], $this->array); - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Integer.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Integer.php deleted file mode 100644 index 5afdc1e0..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Integer.php +++ /dev/null @@ -1,25 +0,0 @@ -isFieldNotEmpty($data)) { - 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; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Ip.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Ip.php deleted file mode 100644 index 754f4f3e..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Ip.php +++ /dev/null @@ -1,15 +0,0 @@ -isFieldNotEmpty($data)) { - return filter_var($data[$this->field], FILTER_VALIDATE_IP) !== false; - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Length.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Length.php deleted file mode 100644 index 7ef241c4..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Length.php +++ /dev/null @@ -1,26 +0,0 @@ -min = $min; - $this->max = $max; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - $length = mb_strlen($data[$this->field], 'UTF-8'); - return $length >= $this->min && $length <= $this->max; - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MaxLength.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MaxLength.php deleted file mode 100644 index 6c4e7771..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MaxLength.php +++ /dev/null @@ -1,24 +0,0 @@ -max = $max; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - $length = mb_strlen($data[$this->field], 'UTF-8'); - return $length <= $this->max; - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MinLength.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MinLength.php deleted file mode 100644 index 0ac4217a..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MinLength.php +++ /dev/null @@ -1,24 +0,0 @@ -min = $min; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - $length = mb_strlen($data[$this->field], 'UTF-8'); - return $length >= $this->min; - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEmpty.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEmpty.php deleted file mode 100644 index bbb14b5b..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEmpty.php +++ /dev/null @@ -1,15 +0,0 @@ -field, $data)) { - return $data[$this->field] !== null && $data[$this->field] !== ''; - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEquals.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEquals.php deleted file mode 100644 index d1d949ea..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEquals.php +++ /dev/null @@ -1,28 +0,0 @@ -field2 = $field2; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - - if (! isset($data[$this->field2])) { - return true; - } - - return $data[$this->field] !== $data[$this->field2]; - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotInArray.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotInArray.php deleted file mode 100644 index 98974c9c..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotInArray.php +++ /dev/null @@ -1,15 +0,0 @@ -isFieldNotEmpty($data)) { - return ! in_array($data[$this->field], $this->array); - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Numeric.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Numeric.php deleted file mode 100644 index 31226866..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Numeric.php +++ /dev/null @@ -1,15 +0,0 @@ -isFieldNotEmpty($data)) { - return is_numeric($data[$this->field]); - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Range.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Range.php deleted file mode 100644 index 065b2b9d..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Range.php +++ /dev/null @@ -1,33 +0,0 @@ -min = $min; - $this->max = $max; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - - if (! is_numeric($data[$this->field])) { - return false; - } - - if ($data[$this->field] < $this->min || $data[$this->field] > $this->max) { - return false; - } - } - - return true; - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Required.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Required.php deleted file mode 100644 index f5e65616..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Required.php +++ /dev/null @@ -1,11 +0,0 @@ -isFieldNotEmpty($data); - } -} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Unique.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Unique.php deleted file mode 100644 index 00caeb54..00000000 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Unique.php +++ /dev/null @@ -1,48 +0,0 @@ -pdo = $pdo; - $this->primary_key = $primary_key; - $this->table = $table; - } - - public function execute(array $data) - { - if ($this->isFieldNotEmpty($data)) { - if (! isset($data[$this->primary_key])) { - $rq = $this->pdo->prepare('SELECT 1 FROM '.$this->table.' WHERE '.$this->field.'=?'); - $rq->execute(array($data[$this->field])); - } - else { - - $rq = $this->pdo->prepare( - 'SELECT 1 FROM '.$this->table.' - WHERE '.$this->field.'=? AND '.$this->primary_key.' != ?' - ); - - $rq->execute(array($data[$this->field], $data[$this->primary_key])); - } - - $result = $rq->fetchColumn(); - - if ($result == 1) { // Postgresql returns an integer but other database returns a string '1' - return false; - } - } - - return true; - } -} -- cgit v1.2.3