Example #1
0
 /**
  * {@inheritdoc}
  */
 public function validateArguments(DataDefinitionInterface $definition, array $arguments)
 {
     $errors = parent::validateArguments($definition, $arguments);
     if (isset($arguments[0])) {
         // Ensure the provided value is given for this data.
         $violations = $this->getTypedDataManager()->create($definition, $arguments[0])->validate();
         foreach ($violations as $violation) {
             $errors[] = $violation->getMessage();
         }
     }
     return $errors;
 }
 /**
  * {@inheritdoc}
  */
 public function validateArguments(DataDefinitionInterface $definition, array $arguments)
 {
     $fails = parent::validateArguments($definition, $arguments);
     $arguments += [0 => 'medium', 1 => '', 2 => NULL, 3 => NULL];
     if ($arguments[0] != 'custom' && $this->dateFormatStorage->load($arguments[0]) === NULL) {
         $fails[] = $this->t('Unkown date format %format given.', ['%format' => $arguments[0]]);
     }
     if ($arguments[0] != 'custom' && $arguments[1]) {
         $fails[] = $this->t("If a custom date format is supplied, 'custom' must be passed as date format.");
     } elseif ($arguments[0] == 'custom' && !$arguments[1]) {
         $fails[] = $this->t("If 'custom' is given as date type, a custom date formatting string must be provided; e.g., 'Y-m-d H:i:s'.");
     }
     return $fails;
     // @todo: Should we validate timezones and langcodes also?
 }