You are here

protected function YamlFormEntityElementsValidator::validateProperties in YAML Form 8

Validate that elements are not using ignored properties.

Return value

array|null If not valid, an array of error messages.

1 call to YamlFormEntityElementsValidator::validateProperties()
YamlFormEntityElementsValidator::validate in src/YamlFormEntityElementsValidator.php
Validate form elements.

File

src/YamlFormEntityElementsValidator.php, line 210

Class

YamlFormEntityElementsValidator
Defines a class to validate form elements.

Namespace

Drupal\yamlform

Code

protected function validateProperties() {
  $ignored_properties = YamlFormElementHelper::getIgnoredProperties($this->elements);
  if ($ignored_properties) {
    $messages = [];
    foreach ($ignored_properties as $ignored_property) {
      $line_numbers = $this
        ->getLineNumbers('/^\\s*(["\']?)' . preg_quote($ignored_property, '/') . '\\1\\s*:/');
      $t_args = [
        '%property' => $ignored_property,
        '@lines' => $this
          ->formatPlural(count($line_numbers), $this
          ->t('line'), $this
          ->t('lines')),
        '@line_numbers' => YamlFormArrayHelper::toString($line_numbers),
      ];
      $messages[] = $this
        ->t('Elements contain an unsupported %property property found on @lines @line_numbers.', $t_args);
    }
    return $messages;
  }
  return NULL;
}