/
ConstraintInterface.php
37 lines (33 loc) · 1.1 KB
/
ConstraintInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Quatrevieux\Form\Validator\Constraint;
use Quatrevieux\Form\RegistryInterface;
use Quatrevieux\Form\Validator\FieldError;
/**
* Base type for define a constraint
* The implementation must be declared as attribute using `#[Attribute(Attribute::TARGET_PROPERTY)]`
*/
interface ConstraintInterface
{
/**
* Constraint code
*
* Should be unique for each constraint.
* Constraint code of this library must be a UUID v5, using this code as namespace and simple class name as name.
*
* For example, a constraint `Foo` must have the code `e9ecc757-fa94-5487-8468-2917e92cae21`
*
* @see FieldError::$code
*/
public const CODE = 'bb8ebf72-1310-4d65-bdb5-9192708543ee';
/**
* Get the related constraint validator
* Can be $this in case of {@see SelfValidatedConstraint}
*
* @param RegistryInterface $registry
*
* @return ConstraintValidatorInterface<static>
*
* @see RegistryInterface::getConstraintValidator()
*/
public function getValidator(RegistryInterface $registry): ConstraintValidatorInterface;
}