Some checks failed
continuous-integration/drone/push Build is failing
- 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
32 lines
769 B
PHP
32 lines
769 B
PHP
<?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());
|
|
}
|
|
}
|
|
}
|