From d82d28fe4a2faabf1c650e2a627fae39b4ac3d5c Mon Sep 17 00:00:00 2001 From: Miguel Borges Date: Sun, 22 Jan 2017 22:39:18 +0000 Subject: [PATCH 1/4] Fix contract --- composer.json | 6 +++--- src/Prettus/Validator/LaravelValidator.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 73eeaed..d4c2c7e 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,13 @@ ], "require": { "php": ">=5.4.0", - "illuminate/support": "~5.0|~5.1", - "illuminate/validation": "~5.0|~5.1" + "illuminate/support": "~5.4", + "illuminate/validation": "~5.4" }, "autoload": { "psr-4": { "Prettus\\Validator\\": "src/Prettus/Validator/" } }, - "minimum-stability": "stable" + "minimum-stability": "dev" } diff --git a/src/Prettus/Validator/LaravelValidator.php b/src/Prettus/Validator/LaravelValidator.php index 28a1ecd..d66a5c3 100644 --- a/src/Prettus/Validator/LaravelValidator.php +++ b/src/Prettus/Validator/LaravelValidator.php @@ -1,6 +1,6 @@ Date: Sun, 22 Jan 2017 22:44:30 +0000 Subject: [PATCH 2/4] Fix PSR-2 --- src/Prettus/Validator/AbstractValidator.php | 49 +++++++++---------- .../Contracts/ValidatorInterface.php | 11 ++--- .../Exceptions/ValidatorException.php | 13 ++--- src/Prettus/Validator/LaravelValidator.php | 10 ++-- 4 files changed, 39 insertions(+), 44 deletions(-) diff --git a/src/Prettus/Validator/AbstractValidator.php b/src/Prettus/Validator/AbstractValidator.php index ca0b183..fc503f1 100644 --- a/src/Prettus/Validator/AbstractValidator.php +++ b/src/Prettus/Validator/AbstractValidator.php @@ -8,8 +8,8 @@ * Class AbstractValidator * @package Prettus\Validator */ -abstract class AbstractValidator implements ValidatorInterface { - +abstract class AbstractValidator implements ValidatorInterface +{ /** * @var int */ @@ -64,7 +64,8 @@ abstract class AbstractValidator implements ValidatorInterface { * @param $id * @return $this */ - public function setId($id){ + public function setId($id) + { $this->id = $id; return $this; } @@ -108,7 +109,7 @@ public function errorsBag() * @param string $action * @return boolean */ - abstract public function passes( $action = null ); + abstract public function passes($action = null); /** * Pass the data and the rules to the validator or throws ValidatorException @@ -119,8 +120,8 @@ abstract public function passes( $action = null ); */ public function passesOrFail($action = null) { - if( !$this->passes($action) ){ - throw new ValidatorException( $this->errorsBag() ); + if (!$this->passes($action)) { + throw new ValidatorException($this->errorsBag()); } return true; @@ -134,11 +135,11 @@ public function passesOrFail($action = null) * @param null $action * @return array */ - public function getRules($action = null){ - + public function getRules($action = null) + { $rules = $this->rules; - if( isset($this->rules[$action]) ){ + if (isset($this->rules[$action])) { $rules = $this->rules[$action]; } @@ -162,14 +163,15 @@ public function setRules(array $rules) * * @return array */ - public function getMessages(){ - + public function getMessages() + { return $this->messages; } /** * Set Custom error messages for Validation * + * @param array $messages * @return $this */ public function setMessages(array $messages) @@ -183,14 +185,15 @@ public function setMessages(array $messages) * * @return array */ - public function getAttributes(){ - + public function getAttributes() + { return $this->attributes; } /** * Set Custom error attributes for Validation * + * @param array $attributes * @return $this */ public function setAttributes(array $attributes) @@ -208,33 +211,28 @@ public function setAttributes(array $attributes) */ protected function parserValidationRules($rules, $id = null) { - - if($id === null) - { + if (null === $id) { return $rules; } - array_walk($rules, function(&$rules, $field) use ($id) - { - if(!is_array($rules)) - { + array_walk($rules, function (&$rules, $field) use ($id) { + if (!is_array($rules)) { $rules = explode("|", $rules); } - foreach($rules as $ruleIdx => $rule) - { + foreach ($rules as $ruleIdx => $rule) { // get name and parameters @list($name, $params) = array_pad(explode(":", $rule), 2, null); // only do someting for the unique rule - if(strtolower($name) != "unique") { + if (strtolower($name) != "unique") { continue; // continue in foreach loop, nothing left to do here } $p = array_map("trim", explode(",", $params)); // set field name to rules key ($field) (laravel convention) - if(!isset($p[1])) { + if (!isset($p[1])) { $p[1] = $field; } @@ -248,5 +246,4 @@ protected function parserValidationRules($rules, $id = null) return $rules; } - -} \ No newline at end of file +} diff --git a/src/Prettus/Validator/Contracts/ValidatorInterface.php b/src/Prettus/Validator/Contracts/ValidatorInterface.php index 685866a..a141d63 100644 --- a/src/Prettus/Validator/Contracts/ValidatorInterface.php +++ b/src/Prettus/Validator/Contracts/ValidatorInterface.php @@ -7,8 +7,8 @@ * Interface ValidatorInterface * @package Prettus\Validator\Contracts */ -interface ValidatorInterface { - +interface ValidatorInterface +{ const RULE_CREATE = 'create'; const RULE_UPDATE = 'update'; @@ -34,8 +34,7 @@ public function with(array $input); * @param string $action * @return boolean */ - public function passes( $action = null ); - + public function passes($action = null); /** * Pass the data and the rules to the validator or throws ValidatorException @@ -44,7 +43,7 @@ public function passes( $action = null ); * @param string $action * @return boolean */ - public function passesOrFail( $action = null ); + public function passesOrFail($action = null); /** * Errors @@ -77,4 +76,4 @@ public function setRules(array $rules); * @return array */ public function getRules($action = null); -} \ No newline at end of file +} diff --git a/src/Prettus/Validator/Exceptions/ValidatorException.php b/src/Prettus/Validator/Exceptions/ValidatorException.php index edc49df..ba6b457 100644 --- a/src/Prettus/Validator/Exceptions/ValidatorException.php +++ b/src/Prettus/Validator/Exceptions/ValidatorException.php @@ -8,8 +8,8 @@ * Class ValidatorException * @package Prettus\Validator\Exceptions */ -class ValidatorException extends \Exception implements Jsonable, Arrayable { - +class ValidatorException extends \Exception implements Jsonable, Arrayable +{ /** * @var MessageBag */ @@ -18,14 +18,16 @@ class ValidatorException extends \Exception implements Jsonable, Arrayable { /** * @param MessageBag $messageBag */ - public function __construct(MessageBag $messageBag){ + public function __construct(MessageBag $messageBag) + { $this->messageBag = $messageBag; } /** * @return MessageBag */ - public function getMessageBag(){ + public function getMessageBag() + { return $this->messageBag; } @@ -52,5 +54,4 @@ public function toJson($options = 0) { return json_encode($this->toArray(), $options); } - -} \ No newline at end of file +} diff --git a/src/Prettus/Validator/LaravelValidator.php b/src/Prettus/Validator/LaravelValidator.php index d66a5c3..d690dd3 100644 --- a/src/Prettus/Validator/LaravelValidator.php +++ b/src/Prettus/Validator/LaravelValidator.php @@ -6,8 +6,8 @@ * Class LaravelValidator * @package Prettus\Validator */ -class LaravelValidator extends AbstractValidator { - +class LaravelValidator extends AbstractValidator +{ /** * Validator * @@ -38,13 +38,11 @@ public function passes($action = null) $attributes = $this->getAttributes(); $validator = $this->validator->make($this->data, $rules, $messages, $attributes); - if( $validator->fails() ) - { + if ($validator->fails()) { $this->errors = $validator->messages(); return false; } return true; } - -} \ No newline at end of file +} From 2ed30597be1046005762fd709358db699a697213 Mon Sep 17 00:00:00 2001 From: Anderson Andrade Date: Sun, 4 Feb 2018 19:13:41 -0300 Subject: [PATCH 3/4] Update phpdocs and add theme docs --- _config.yml | 1 + composer.json | 2 +- src/Prettus/Validator/AbstractValidator.php | 1 + src/Prettus/Validator/Contracts/ValidatorInterface.php | 1 + src/Prettus/Validator/Exceptions/ValidatorException.php | 1 + src/Prettus/Validator/LaravelValidator.php | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 _config.yml diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/composer.json b/composer.json index d4c2c7e..33361d3 100644 --- a/composer.json +++ b/composer.json @@ -18,5 +18,5 @@ "Prettus\\Validator\\": "src/Prettus/Validator/" } }, - "minimum-stability": "dev" + "minimum-stability": "stable" } diff --git a/src/Prettus/Validator/AbstractValidator.php b/src/Prettus/Validator/AbstractValidator.php index fc503f1..e219c3a 100644 --- a/src/Prettus/Validator/AbstractValidator.php +++ b/src/Prettus/Validator/AbstractValidator.php @@ -7,6 +7,7 @@ /** * Class AbstractValidator * @package Prettus\Validator + * @author Anderson Andrade */ abstract class AbstractValidator implements ValidatorInterface { diff --git a/src/Prettus/Validator/Contracts/ValidatorInterface.php b/src/Prettus/Validator/Contracts/ValidatorInterface.php index a141d63..03072ae 100644 --- a/src/Prettus/Validator/Contracts/ValidatorInterface.php +++ b/src/Prettus/Validator/Contracts/ValidatorInterface.php @@ -6,6 +6,7 @@ /** * Interface ValidatorInterface * @package Prettus\Validator\Contracts + * @author Anderson Andrade */ interface ValidatorInterface { diff --git a/src/Prettus/Validator/Exceptions/ValidatorException.php b/src/Prettus/Validator/Exceptions/ValidatorException.php index ba6b457..d0cb660 100644 --- a/src/Prettus/Validator/Exceptions/ValidatorException.php +++ b/src/Prettus/Validator/Exceptions/ValidatorException.php @@ -7,6 +7,7 @@ /** * Class ValidatorException * @package Prettus\Validator\Exceptions + * @author Anderson Andrade */ class ValidatorException extends \Exception implements Jsonable, Arrayable { diff --git a/src/Prettus/Validator/LaravelValidator.php b/src/Prettus/Validator/LaravelValidator.php index d690dd3..42bc053 100644 --- a/src/Prettus/Validator/LaravelValidator.php +++ b/src/Prettus/Validator/LaravelValidator.php @@ -5,6 +5,7 @@ /** * Class LaravelValidator * @package Prettus\Validator + * @author Anderson Andrade */ class LaravelValidator extends AbstractValidator { From dd7efc66ac03812880b5a073af96be664134e247 Mon Sep 17 00:00:00 2001 From: Anderson Andrade Date: Sun, 4 Feb 2018 19:15:25 -0300 Subject: [PATCH 4/4] Update composer --- composer.json | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 33361d3..cdbf0c8 100644 --- a/composer.json +++ b/composer.json @@ -5,9 +5,19 @@ "authors": [ { "name": "Anderson Andrade", - "email": "contato@andersonandra.de" + "homepage": "http://andersonandra.de", + "email": "contato@andersonandra.de", + "role": "Developer" } ], + "homepage": "http://andersao.github.io/laravel-validation", + "support": { + "email": "contato@andersonandra.de", + "issues":"https://github.com/andersao/laravel-validation/issues", + "wiki":"https://github.com/andersao/laravel-validation", + "source":"https://github.com/andersao/laravel-validation", + "docs": "http://andersao.github.io/laravel-validation" + }, "require": { "php": ">=5.4.0", "illuminate/support": "~5.4", @@ -19,4 +29,4 @@ } }, "minimum-stability": "stable" -} +} \ No newline at end of file