当前位置: 首页>>代码示例>>PHP>>正文


PHP ExecutionContextInterface::buildViolation方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:joshcrawmer4,项目名称:snaFoo,代码行数:8,代码来源:Suggestion.php

示例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();
     }
 }
开发者ID:cimus,项目名称:yandex-direct-api,代码行数:13,代码来源:BidSetItem.php

示例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();
     }
 }
开发者ID:cimus,项目名称:yandex-direct-api,代码行数:12,代码来源:AdGroupsSelectionCriteria.php

示例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();
     }
 }
开发者ID:nk2ge5k,项目名称:yandex-direct-api,代码行数:12,代码来源:SetBidsItem.php

示例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();
     }
 }
开发者ID:sanborino,项目名称:clinica,代码行数:9,代码来源:Encargado.php

示例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();
   }
 }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:12,代码来源:CropTypeMachineNameValidationConstraintValidator.php

示例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();
   }
 }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:12,代码来源:CropTypeAspectRatioValidationConstraintValidator.php

示例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();
     }
 }
开发者ID:cimus,项目名称:yandex-direct-api,代码行数:13,代码来源:TimeTargetingOnPublicHolidays.php

示例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();
     }
 }
开发者ID:cimus,项目名称:yandex-direct-api,代码行数:13,代码来源:BidModifierAddItem.php

示例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();
     }
 }
开发者ID:cimus,项目名称:yandex-direct-api,代码行数:13,代码来源:TextAdAdd.php

示例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;
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:9,代码来源:PostMessageIntent.php

示例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();
         }
     }
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:13,代码来源:WorkflowFieldConstraintValidator.php

示例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();
     }
 }
开发者ID:sanborino,项目名称:clinica,代码行数:11,代码来源:Pacientepatologia.php

示例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;
     }
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:11,代码来源:PasswordRecoveryCompleteIntent.php

示例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;
     }
 }
开发者ID:Newton-Labs,项目名称:HospitalRecord,代码行数:11,代码来源:ConsultaType.php


注:本文中的Symfony\Component\Validator\Context\ExecutionContextInterface::buildViolation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。