Skip to content

Commit

Permalink
Collections now use the Validation component.
Browse files Browse the repository at this point in the history
  • Loading branch information
SidRoberts committed May 3, 2017
1 parent cf1abda commit 1781879
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 1,325 deletions.
45 changes: 28 additions & 17 deletions phalcon/mvc/collection.zep
Expand Up @@ -641,25 +641,29 @@ abstract class Collection implements EntityInterface, CollectionInterface, Injec
* Executes validators on every validation call
*
*<code>
* use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn;
* use Phalcon\Mvc\Collection;
* use Phalcon\Validation;
* use Phalcon\Validation\Validator\ExclusionIn;
*
* class Subscriptors extends \Phalcon\Mvc\Collection
* class Subscriptors extends Collection
* {
* public function validation()
* {
* // Old, deprecated syntax, use new one below
* $this->validate(
* $validator = new Validation();
*
* $validator->add(
* "status",
* new ExclusionIn(
* [
* "field" => "status",
* "domain" => ["A", "I"],
* "domain" => [
* "A",
* "I",
* ],
* ]
* )
* );
*
* if ($this->validationHasFailed() == true) {
* return false;
* }
* return $this->validate($validator);
* }
* }
*</code>
Expand Down Expand Up @@ -729,30 +733,37 @@ abstract class Collection implements EntityInterface, CollectionInterface, Injec
} else {
throw new Exception("You should pass Phalcon\\Mvc\\Model\\ValidatorInterface or Phalcon\\ValidationInterface object");
}

return messages;
}

/**
* Check whether validation process has generated any messages
*
*<code>
* use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn;
* use Phalcon\Mvc\Collection;
* use Phalcon\Validation;
* use Phalcon\Validation\Validator\ExclusionIn;
*
* class Subscriptors extends \Phalcon\Mvc\Collection
* class Subscriptors extends Collection
* {
* public function validation()
* {
* $this->validate(
* $validator = new Validation();
*
* $validator->validate(
* "status",
* new ExclusionIn(
* [
* "field" => "status",
* "domain" => ["A", "I"],
* "domain" => [
* "A",
* "I",
* ],
* ]
* )
* );
*
* if ($this->validationHasFailed() == true) {
* return false;
* }
* return $this->validate($validator);
* }
* }
*</code>
Expand Down
96 changes: 0 additions & 96 deletions phalcon/mvc/model/validator/email.zep

This file was deleted.

112 changes: 0 additions & 112 deletions phalcon/mvc/model/validator/exclusionin.zep

This file was deleted.

0 comments on commit 1781879

Please sign in to comment.