本文整理汇总了PHP中Symfony\Component\Validator\Context\ExecutionContextInterface::buildViolation方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecutionContextInterface::buildViolation方法的具体用法?PHP ExecutionContextInterface::buildViolation怎么用?PHP ExecutionContextInterface::buildViolation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Validator\Context\ExecutionContextInterface
的用法示例。
在下文中一共展示了ExecutionContextInterface::buildViolation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate(ExecutionContextInterface $context)
{
if (!empty($this->snackSuggestion) && empty($this->location)) {
$context->buildViolation('You must enter a purchasing location')->atPath('location')->addViolation();
} elseif (empty($this->snackSuggestion) && !empty($this->location)) {
$context->buildViolation('You must enter a snack suggestion')->atPath('snackSuggestion')->addViolation();
}
}
示例2: isValid
/**
* @Assert\Callback()
* @param ExecutionContextInterface $context
*/
public function isValid(ExecutionContextInterface $context)
{
if (!$this->CampaignId && !$this->AdGroupId && !$this->KeywordId) {
$context->buildViolation('Должно быть указано одно из следующих значений: CampaignId, AdGroupId, KeywordId')->atPath('CampaignId')->atPath('AdGroupId')->atPath('KeywordId')->addViolation();
}
if (!$this->Bid && !$this->ContextBid && !$this->StrategyPriority) {
$context->buildViolation('Должно быть указано одно из следующих значений: Bid, ContextBid, StrategyPriority')->atPath('Bid')->atPath('ContextBid')->atPath('StrategyPriority')->addViolation();
}
}
示例3: isValid
/**
* @param ExecutionContextInterface $context
*/
public function isValid(ExecutionContextInterface $context)
{
if (!($this->Ids == [] && count($this->CampaignIds) > 0)) {
$context->buildViolation('CampaignIds должны быть указаны, если Ids пусты')->atPath('CampaignIds')->addViolation();
}
if (!($this->CampaignIds == [] && count($this->Ids) > 0)) {
$context->buildViolation('Ids должны быть указаны, если CampaignIds пусты')->atPath('Ids')->addViolation();
}
}
示例4: isValid
/**
* @param ExecutionContextInterface $context
*/
public function isValid(ExecutionContextInterface $context)
{
if (!$this->CampaignId and !$this->AdGroupId and !$this->Id) {
$context->buildViolation('Необходимо указать CampaignId либо AdGroupId либо Id')->atPath('CampaignId')->atPath('AdGroupId')->atPath('Id')->addViolation();
}
if (!$this->Bid and !$this->StrategyPriority) {
$context->buildViolation('Необходимо указать Bid либо StrategyPriority')->atPath('Bid')->atPath('StrategyPriority')->addViolation();
}
}
示例5: fechaMayor
public function fechaMayor(ExecutionContextInterface $context)
{
if ($this->getFechanacimiento() > new \DateTime('today')) {
$context->buildViolation('No puede haber nacido en el futuro.')->atPath('fechanacimiento')->addViolation();
}
if ($this->getFechanacimiento()->diff(new \DateTime('today'))->y < 18) {
$context->buildViolation('Debe ser mayor de 18 años.')->atPath('fechanacimiento')->addViolation();
}
}
示例6: validate
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint) {
// '0' is invalid, since elsewhere we check it using empty().
/** @var \Drupal\crop\Entity\CropType $value */
if (trim($value->id()) == '0') {
$this->context->buildViolation($constraint->message)
->atPath('id')
->addViolation();
}
}
示例7: validate
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint) {
/** @var \Drupal\crop\Entity\CropType $value */
$aspect_ratio = $value->getAspectRatio();
if (!empty($aspect_ratio) && !preg_match($value::VALIDATION_REGEXP, $aspect_ratio)) {
$this->context->buildViolation($constraint->message)
->atPath('aspect_ratio')
->addViolation();
}
}
示例8: isValid
/**
* @Assert\Callback()
* @param ExecutionContextInterface $context
*/
public function isValid(ExecutionContextInterface $context)
{
if ($this->SuspendOnHolidays == new YesNoEnum(YesNoEnum::NO) && $this->StartHour === null) {
$context->buildViolation('При SuspendOnHolidays=NO должен быть указан параметр StartHour')->atPath('StartHour')->addViolation();
}
if ($this->SuspendOnHolidays == new YesNoEnum(YesNoEnum::NO) && $this->EndHour === null) {
$context->buildViolation('При SuspendOnHolidays=NO должен быть указан параметр EndHour')->atPath('EndHour')->addViolation();
}
}
示例9: isValid
/**
* @Assert\Callback()
* @param ExecutionContextInterface $context
*/
public function isValid(ExecutionContextInterface $context)
{
if (!$this->CampaignId && !$this->AdGroupId) {
$context->buildViolation('Должно быть указано одно из следующих значений: CampaignId, AdGroupId')->atPath('CampaignId')->atPath('AdGroupId')->addViolation();
}
if (!$this->MobileAdjustment && !$this->DemographicsAdjustments && !$this->RetargetingAdjustments) {
$context->buildViolation('Должно быть указано одно из следующих значений: MobileAdjustment, DemographicsAdjustments, RetargetingAdjustments')->atPath('MobileAdjustment')->atPath('DemographicsAdjustments')->atPath('RetargetingAdjustments')->addViolation();
}
}
示例10: isValid
/**
* @Assert\Callback()
* @param ExecutionContextInterface $context
*/
public function isValid(ExecutionContextInterface $context)
{
if (!$this->Href && !$this->VCardId) {
$context->buildViolation('Необходимо указать Href или VCardId')->atPath('Href')->atPath('VCardId')->addViolation();
}
if (!$this->Href && $this->SitelinkSetId) {
$context->buildViolation('Нельзя указать SitelinkSetId при пустом Href')->atPath('SitelinkSetId')->addViolation();
}
}
示例11: validate
public function validate(ExecutionContextInterface $context)
{
if (empty($this->authorEmail) && empty($this->authorPhone)) {
$context->buildViolation('Please specify either e-mail or phone number.')->atPath('authorEmail')->addViolation();
$context->buildViolation('Please specify either e-mail or phone number.')->atPath('authorPhone')->addViolation();
return false;
}
return true;
}
示例12: validate
/**
* {@inheritdoc}
*/
public function validate($entity, Constraint $constraint)
{
// Workflow field name on comment has special requirements.
$field_storage = $entity->getFieldDefinition()->getFieldStorageDefinition();
if ($field_storage->getTargetEntityTypeId() == 'comment') {
if (!$this->isValidFieldname($field_storage, $entity->getEntity())) {
$this->context->buildViolation($constraint->messageFieldname)->atPath('fieldnameOnComment')->addViolation();
}
}
}
示例13: fechaMayor
public function fechaMayor(ExecutionContextInterface $context)
{
if ($this->getIdpaciente()) {
if ($this->getFechadiagnostico() < $this->getIdpaciente()->getFechanacimiento()) {
$context->buildViolation(sprintf('Esta fecha no puede ser menor que la fecha de nacimiento del paciente. (%s)', $this->getIdpaciente()->getFechanacimiento()->format('Y-m-d')))->atPath('fechadiagnostico')->addViolation();
}
}
if ($this->getFechadiagnostico() > new \DateTime('today')) {
$context->buildViolation('Esta fecha no puede ser mayor que la fecha de hoy.')->atPath('fechadiagnostico')->addViolation();
}
}
示例14: validate
public function validate(ExecutionContextInterface $context)
{
if ($this->password != $this->repeatPassword) {
$context->buildViolation('The specified passwords are not identical!')->atPath('password')->addViolation();
return false;
}
if (!PasswordBuilder::isPasswordStrongEnough($this->password)) {
$context->buildViolation('The password must contain lowercase, uppercase letters and numbers.')->atPath('password')->addViolation();
return false;
}
}
示例15: validate
public function validate($data, ExecutionContextInterface $context)
{
if (isset($data['consulta_dpi_nombre_apellidos']) && isset($data['consulta_fecha_ingreso']) && isset($data['consulta_procedimiento_realizado'])) {
$context->buildViolation('Debe seleccionar sólo un método de consulta')->addViolation();
return;
}
if (!isset($data['consulta_dpi_nombre_apellidos']) && !isset($data['consulta_fecha_ingreso']) && !isset($data['consulta_procedimiento_realizado'])) {
$context->buildViolation('Debe seleccionar al menos un método de consulta')->addViolation();
return;
}
}