Skip to content

MySchoolManagement/assert-constraint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Assert bridge for Symfony

Latest Stable Version Total Downloads Latest Unstable Version License

This is a simple bridge for using beberlei/assert assertions as constraints for the Symfony Validator component.

Installation

Using Composer:

composer require myschoolmanagement/assert-constraint

Configuration

If you are using your own Assertion class or your own Exception class then you must configure these by setting AssertionConstraint\AssertionValidator::$assertClass and AssertionConstraint\AssertionValidator::$assertExceptionClass. These are both static properties.

Generating new constraints

There is a helper for generating the constraint classes in bin. This is also copied to vendor/bin.

Prototype

Usage: generate-constraints.php <path-to-class-file> <fqdn class> <output-namespace> <directory-to-output-classes>

Example Usage:

php vendor/bin/generate-constraints.php vendor/beberlei/assert/lib/Assert/Assertion.php Assert\\Assertion MyBundle\\Constraint src/MyBundle/Constraint

This will detect all the assertions on the Assert\Assertion class and output constraint files in src/MyBundle/Constraint in the MyBundle\Constraint namespace.

The generator will give best effort to detect the assertion parameters and add those to the constraint class so they can be configured through the annotation.

About

Simple bridge for using beberlei/assert assertions as constraints for the Symfony Validator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages