chubbyphp / chubbyphp-validation
Chubbyphp Validate
Installs: 17 613
Dependents: 2
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 0
Requires (Dev)
- chubbyphp/chubbyphp-container: ^2.2
- chubbyphp/chubbyphp-dev-helper: dev-master
- chubbyphp/chubbyphp-laminas-config-factory: ^1.3
- chubbyphp/chubbyphp-mock: ^1.7
- doctrine/collections: ^2.1.4
- doctrine/persistence: ^3.2
- infection/infection: ^0.27.8
- mongodb/mongodb: ^1.17
- php-coveralls/php-coveralls: ^2.7
- phpstan/extension-installer: ^1.3.1
- phpstan/phpstan: ^1.10.47
- phpunit/phpunit: ^10.5.1
- pimple/pimple: ^3.5
- psr/container: ^2.0.2
- symfony/validator: ^5.4.31|^6.3.8|^7.0
- dev-master / 4.0.x-dev
- 4.0.0
- 3.12.4
- 3.12.3
- 3.12.2
- 3.12.1
- 3.12.0
- 3.11.1
- 3.11.0
- 3.10.0
- 3.9.0
- 3.8.0
- 3.7.1
- 3.7.0
- 3.6.2
- 3.6.1
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.1
- 3.3.0
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.2
- 3.0.1
- 3.0.0
- 3.0-beta2
- 3.0-beta1
- v2.x-dev
- 2.2.0
- 2.1.1
- 2.1.0
- 2.1-beta1
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0-alpha14
- 2.0-alpha13
- 2.0-alpha12
- 2.0-alpha11
- 2.0-alpha10
- 2.0-alpha9
- 2.0-alpha8
- 2.0-alpha7
- 2.0-alpha6
- 2.0-alpha5
- 2.0-alpha4
- 2.0-alpha3
- 2.0-alpha2
- 2.0-alpha1
- v1.x-dev
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 1.0.0-beta2
- 1.0.0-beta1
- 1.0.0-alpha1
This package is auto-updated.
Last update: 2024-07-06 14:12:56 UTC
README
chubbyphp-validation
Description
A simple validation.
DEPRECATED: No personal interest anymore and based on stats nobody seems to use it. Feel free to create an issue if you disagree. Please take a look to chubbyphp-parsing its a different concept. But i believe parsing is the way to go instead of deserialze/validate.
Requirements
- php: ^8.1
- psr/log: ^2.0|^3.0
Suggest
- chubbyphp/chubbyphp-container: ^2.2
- pimple/pimple: ^3.5
- psr/container: ^2.0.2
Installation
Through Composer as chubbyphp/chubbyphp-validation.
composer require chubbyphp/chubbyphp-validation "^4.0"
Usage
Accessor
Constraint
- AllConstraint
- BlankConstraint
- CallbackConstraint
- ChoiceConstraint
- CoordinateArrayConstraint
- CoordinateConstraint
- CountConstraint
- DateTimeConstraint
- EmailConstraint
- FalseConstraint
- MapConstraint
- NotBlankConstraint
- NotNullConstraint
- NullConstraint
- NumericConstraint
- NumericRangeConstraint
- TrueConstraint
- TypeConstraint
- ValidConstraint
Doctrine
Symfony
Error
Mapping
- CallableValidationMappingProvider
- LazyValidationMappingProvider
- ValidationClassMapping
- ValidationClassMappingBuilder
- ValidationMappingProviderRegistry
- ValidationPropertyMapping
- ValidationPropertyMappingBuilder
ValidationMappingProvider
<?php namespace MyProject\Model; final class Model { /** * @var array<\DateTime> */ private $dates; }
<?php namespace MyProject\Mapping\Validation; use Chubbyphp\Validation\Constraint\AllConstraint; use Chubbyphp\Validation\Constraint\DateTimeConstraint; use Chubbyphp\Validation\Constraint\NotBlankConstraint; use Chubbyphp\Validation\Constraint\NotNullConstraint; use Chubbyphp\Validation\Mapping\ValidationClassMappingBuilder; use Chubbyphp\Validation\Mapping\ValidationClassMappingInterface; use Chubbyphp\Validation\Mapping\ValidationMappingProviderInterface; use Chubbyphp\Validation\Mapping\ValidationPropertyMappingBuilder; use Chubbyphp\Validation\Mapping\ValidationPropertyMappingInterface; use MyProject\Model\Model; final class ModelValidationMappingProvider implements ValidationMappingProviderInterface { /** * @return string */ public function getClass(): string { return Model::class; } /** * @param string $path * * @return ValidationClassMappingInterface */ public function getValidationClassMapping(string $path): ValidationClassMappingInterface { return ValidationClassMappingBuilder::create([])->getMapping(); } /** * @param string $path * @param string|null $type * * @return ValidationPropertyMappingInterface[] */ public function getValidationPropertyMappings(string $path, string $type = null): array { return [ ValidationPropertyMappingBuilder::create('dates', [ new AllConstraint([ new NotNullConstraint(), new NotBlankConstraint(), new DateTimeConstraint('d.m.Y'), ]), ])->getMapping(), ]; } }
ServiceFactory
chubbyphp-container
chubbyphp-laminas-config-factory
ServiceProvider
Validator
<?php namespace MyProject; use Chubbyphp\Validation\Mapping\ValidationMappingProviderRegistry; use Chubbyphp\Validation\ValidatorContextInterface; use Chubbyphp\Validation\Validator; use MyProject\Mapping\Validation\ModelValidationMappingProvider; use MyProject\Model\Model; $logger = ...; $validator = new Validator( new ValidationMappingProviderRegistry([ new ModelValidationMappingProvider() ]), $logger ); $model = new Model; /** @var ValidatorContextInterface $context */ $context = ...; $errors = $validator->validate( $model, $context );
Copyright
2024 Dominik Zogg