mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-15 04:44:36 +02:00
Added constraints for selectable attribute.
This commit is contained in:
parent
408d98c6e1
commit
51be176418
12 changed files with 169 additions and 0 deletions
|
@ -37,6 +37,7 @@ use Symfony\Bundle\MakerBundle\Str;
|
|||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* The validator for the NoneOfItsChildren annotation.
|
||||
|
@ -62,6 +63,11 @@ class NoneOfItsChildrenValidator extends ConstraintValidator
|
|||
return;
|
||||
}
|
||||
|
||||
//Check type of value. Validating only works for StructuralDBElements
|
||||
if (!$value instanceof StructuralDBElement) {
|
||||
throw new UnexpectedValueException($value, 'StructuralDBElement');
|
||||
}
|
||||
|
||||
//Check if the object is assigned to itself
|
||||
/** @var StructuralDBElement $entity */
|
||||
$entity = $this->context->getObject();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue