Skip to content

nope7777/symfony-validators-bundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Symfony validators

Usage examples

NestedObject and NestedObjects validators

use N7\SymfonyValidatorsBundle\Validator\NestedObject;
use N7\SymfonyValidatorsBundle\Validator\NestedObjects;
use Symfony\Component\Validator\Constraints;

final class Book
{
    #[Constraints\NotBlank]
    #[Constraints\Type('integer')]
    private int $id;

    #[Constraints\NotBlank]
    #[Constraints\Type('string')]
    private string $title;
}

final class Reader
{
    #[Constraints\NotBlank]
    #[Constraints\Type('integer')]
    private int $id;

    #[Constraints\NotBlank]
    #[NestedObject(Book::class)]
    private Book $favoriteBook;

    /**
     * @var Book[]
     */
    #[Constraints\NotBlank]
    #[NestedObjects(Book::class)]
    private array $readedBooks;
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages