1. Go to this page and download the library: Download paliari/doctrine-validator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
paliari / doctrine-validator example snippets
// Create your model extended to AbstractRansackModel.
class YourModel
{
use \Paliari\Doctrine\TraitValidatorModel;
//... fields ...
/**
* Override the method getEm is
}
}
class YourModel extends \Paliari\Doctrine\AbstractValidatorModel
{
//... fields ...
/**
* Override the method getEm is function getEM()
{
// return EntityManager
}
}
protected static $validates_custom = ['yourMethodName', 'otherYourMethodName'];
public function yourMethodName() {
if ($name == 'example') {
$this->errors->add('name', '"name" cannot be "example"');
}
}
public function otherYourMethodName() {
// Do something here
}
protected static $before_validation = ['yourCallbackName'];
public function yourCallbackName() { /* Do something here */}