Hello. How i can validate mongodb collection by Uniqueness? I get error
Call to undefined method ::getschema()
my code is
use Phalcon\Mvc\Model\Validator\Uniqueness;
use Phalcon\Mvc\Model\Validator\PresenceOf;
use Phalcon\Mvc\MongoCollection;
class Users extends MongoCollection {
public $name;
public $password;
public function validation() {
$this->validate(new PresenceOf([
"field" => "name",
"message" => "The name is required",
]));
$this->validate(new PresenceOf([
"field" => "password",
"message" => "The pasword is required",
]));
$this->validate(new Uniqueness([
"field" => "name",
"message" => "Name must be unique",
]));
return $this->validationHasFailed() !== true;
}
}