walnut / lib_data
There is no license information available for the latest version (dev-main) of this package.
dev-main
2024-09-16 10:15 UTC
Requires
- php: >=8.2
Requires (Dev)
- phpunit/phpunit: >=9.5.20
- vimeo/psalm: >=4.23.0
This package is not auto-updated.
Last update: 2024-10-29 09:02:56 UTC
README
Attribute based data importer and validator
Examples
Book
final readonly class BookData { public function __construct( #[IntegerData(minimum: 1, maximum: 999999)] public int $numPages, #[StringData(minLength: 1, maxLength: 100)] public string $authorName, #[IntegerData(minimum: 1, maximum: 9999)] public int $issueYear, #[StringData(minLength: 1, maxLength: 100)] public string $publisherName, #[StringData(minLength: 1, maxLength: 30)] public string $language ) {} }
$bookData = [ 'numPages' => 10, 'authorName' => 'John Lock', 'issueYear' => 2003, 'publisherName' => "O'Really?", 'language' => 'English' ]; $bookObject = $importer->import($bookData, BookData::class); $importer->validate($bookObject); //ok