- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
This commit is contained in:
31
app/Data/Validation/NetteValidator.php
Normal file
31
app/Data/Validation/NetteValidator.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Data\Validation;
|
||||
|
||||
use Nette\Schema\Expect;
|
||||
use Nette\Schema\Processor;
|
||||
use Nette\Schema\Schema;
|
||||
use Nette\Schema\ValidationException;
|
||||
|
||||
class NetteValidator extends Validator implements ValidatesArray
|
||||
{
|
||||
private Processor $schemaProcessor;
|
||||
private Schema $schema;
|
||||
|
||||
public function __construct(Processor $schemaProcessor, Schema $schema)
|
||||
{
|
||||
$this->schemaProcessor = $schemaProcessor;
|
||||
$this->schema = $schema;
|
||||
}
|
||||
|
||||
public function validateArray(array $items): ValidationResult
|
||||
{
|
||||
try {
|
||||
$this->schemaProcessor->process($this->schema, $items);
|
||||
|
||||
return $this->success();
|
||||
} catch (ValidationException $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user