ConfiguredArticle エンティティ内には、次のようなメソッドを含めることができます。
public function isLengthValid(ExecutionContextInterface $context) {
if ($this->getLength < $this->getArticleConfiguration()->getMinLength()) {
$context->addViolationAt('length', 'The length does not satisfy the minimum length', array(), null);
}
if ($this->getLength > $this->getArticleConfiguration()->getMaxLength()) {
$context->addViolationAt('length', 'The length does not satisfy the maximum length', array(), null);
}
}
public function isWidthValid(ExecutionContextInterface $context) {
if ($this->getWidth < $this->getArticleConfiguration()->getMinWidth()) {
$context->addViolationAt('width', 'The width does not satisfy the minimum width', array(), null);
}
if ($this->getWidth > $this->getArticleConfiguration()->getMaxWidth()) {
$context->addViolationAt('width', 'The width does not satisfy the maximum width', array(), null);
}
}
このページで検証にコールバック メソッドを使用する方法について詳しくは、http ://symfony.com/doc/current/reference/constraints/Callback.html をご覧ください。