PHP code example of aneterial / laravel-data-validator
1. Go to this page and download the library: Download aneterial/laravel-data-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/ */
aneterial / laravel-data-validator example snippets
use DataValidator\Attributes\RequestProperty;
final readonly class ExampleDTO {
#[RequestProperty(property: 'id', rules: '
final readonly class ExampleDTO {
...
/** @var string[] $emails */
#[RequestProperty(property: 'emails', rules: 'Rules: 'int|min:0')]
public array $ids;
...
}
final readonly class ExampleDTO {
#[RequestProperty(property: 'id', rules: 'integer|min:0')]
public ?int $id;
#[RequestProperty(property: 'email', rules: 'string|email')]
public ?string $email;
/** @var int[] $ids */
#[RequestProperty(property: 'ids', rules: 'list', listRules: 'int|min:0')]
public array $ids;
}
final readonly class ExampleDTO {
...
#[RequestProperty(property: 'child', rules: 'utes
final readonly class NestedDTO {
#[RequestProperty(property: 'id', rules: '
final readonly class ExampleDTO {
...
/** @var NestedDTO[] $children */
#[RequestProperty(property: 'children', rules: '
final readonly class ExampleDTO {
...
#[RequestProperty(property: 'enum', rules: '
final readonly class ExampleDTO {
...
/** @var AnApplicationEnum[] $enums */
#[RequestProperty(property: 'enums', rules: '
final readonly class ExampleDTO {
...
#[RequestProperty(property: 'child', rules: 'utes
final readonly class NestedDTO {
#[RequestProperty(property: 'id', rules: '
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.