public function StateConstraintValidator::validate in State Machine 8
File
- src/
Plugin/ Validation/ Constraint/ StateConstraintValidator.php, line 18
Class
- StateConstraintValidator
- Validates the State constraint.
Namespace
Drupal\state_machine\Plugin\Validation\ConstraintCode
public function validate($value, Constraint $constraint) {
if (!$value
->getEntity()
->isNew() && !$value
->isValid()) {
$this->context
->addViolation($constraint->message, [
'@state' => $value->value,
]);
}
}