function elasticsearch_connector_validate_type_field in Elasticsearch Connector 7.5
Same name and namespace in other branches
- 7 elasticsearch_connector.module \elasticsearch_connector_validate_type_field()
- 7.2 elasticsearch_connector.module \elasticsearch_connector_validate_type_field()
Helper function you can use with #element_validate of any form element you want to be validated as Elasticsearch type field.
Parameters
array $element:
array $form_state:
array $form:
Return value
void
File
- ./
elasticsearch_connector.module, line 995 - This module provide an interface to connecting to the elasticsearch cluster and implementing the official Elasticsearch library.
Code
function elasticsearch_connector_validate_type_field($element, &$form_state, $form) {
if (!empty($element['#value']) && !preg_match('/^[a-z][a-z0-9_]*$/i', $element['#value'])) {
form_error($element, t('Enter a type name that begins with a letter and contains only letters, numbers, and underscores.'));
}
}