1. Go to this page and download the library: Download two-bros/validation-service 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/ */
use TwoBros\ValidationService\Services\Validation\LaravelValidator;
class ModelCreateValidator extends LaravelValidator
{
protected $rules = [
'name' => '
$modelValidator = new ModelCreateValidator($this->app['validator']);
if ($modelValidator->with($inputArray)
->passes()) {
// Do some stuff for passing
} else {
// Get the errors
$validationErrors = $modelValidator->errors();
// Do some stuff for failing
}
$messages = [
'dator = new ModelCreateValidator($this->app['validator']);
if ($modelValidator->with($inputArray, $messages)
->passes()) {
// Do some stuff for passing
} else {
// Get the errors
$validationErrors = $modelValidator->errors();
// Do some stuff for failing
}
$messages = [
'dator = new ModelCreateValidator($this->app['validator']);
if ($modelValidator->with($inputArray)
->withMessages($messages)
->passes()) {
// Do some stuff for passing
} else {
// Get the errors
$validationErrors = $modelValidator->errors();
// Do some stuff for failing
}
$modelValidator = new ModelCreateValidator($this->app['validator']);
if ($modelValidator->with($inputArray)
->setUniqueId('email', $modelToUpdate->id)
->addRuntimeValidationRules()
->passes()) {
// Do some stuff for passing
} else {
// Get the errors
$validationErrors = $modelValidator->errors();
// Do some stuff for failing
}
public function update(ModelValidator $modelValidator) {
if ($modelValidator->with($inputArray)
->setUniqueId('email', $modelToUpdate->id)
->addRuntimeValidationRules()
->passes()) {
// Do some stuff for passing
} else {
// Get the errors
$validationErrors = $modelValidator->errors();
// Do some stuff for failing
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.