protected static function WebformCodeMirror::validateYaml in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Element/WebformCodeMirror.php \Drupal\webform\Element\WebformCodeMirror::validateYaml()
Validate YAML.
Parameters
array $element: The form element whose value is being validated.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array $complete_form: The complete form structure.
Return value
array|null An array of error messages.
1 call to WebformCodeMirror::validateYaml()
- WebformCodeMirror::getErrors in src/
Element/ WebformCodeMirror.php - Get validation errors.
File
- src/
Element/ WebformCodeMirror.php, line 337
Class
- WebformCodeMirror
- Provides a webform element for using CodeMirror.
Namespace
Drupal\webform\ElementCode
protected static function validateYaml($element, FormStateInterface $form_state, $complete_form) {
try {
$value = $element['#value'];
$data = Yaml::decode($value);
if (!is_array($data) && $value) {
throw new \Exception(t('YAML must contain an associative array of elements.'));
}
return NULL;
} catch (\Exception $exception) {
return [
$exception
->getMessage(),
];
}
}