PHP code example of myaza-software / schema-validator
1. Go to this page and download the library: Download myaza-software/schema-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/ */
myaza-software / schema-validator example snippets
declare(strict_types=1);
namespace App;
use App\DTO\RefundWebhook;
use SchemaValidator\Schema;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
final class ValidateDtoCommand extends Command
{
protected static $defaultName = 'validate:dto';
public function __construct(
private ValidatorInterface $validator,
private SerializerInterface $serializer,
){
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$errors = $this->validator->validate([
'type' => 123123,
'uuid' => '',
'price' => [
'vault' => [
'value' => 1,
'names' => [
['value' => 1, 'createdAt' => '']
]
],'value' => 1]
], new Schema([
'type' => RefundWebhook::class,
'strictTypes' => true
]));
$output->write($this->serializer->serialize($errors,'json'));
return self::SUCCESS;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.