import { componentTypes } from '@data-driven-forms/react-form-renderer';
import debouncePromise from '../../helpers/promise-debounce';
import { http } from '../../http_api';

export const asyncValidator = value =>
  http.get('/catalog/servicetemplates_names')
    .then((json) => {
      if (json.names.includes(value)) {
        return __('Name has already been taken');
      }
      if (value === '' || value === undefined) {
        return __("Name can't be blank");
      }
      return undefined;
    });
const asyncValidatorDebounced = debouncePromise(asyncValidator);

function createSchema() {
  const fields = [
    {
      component: componentTypes.TEXT_FIELD,
      name: 'name',
      validate: [
        value => asyncValidatorDebounced(value),
      ],
      label: __('Name'),
      maxLength: 40,
    }];
  return { fields };
}

export default createSchema;

@@ -807,16 +807,68 @@
 th: 40,%0A
+      autoFocus: true,%0A      validateOnMount: true,%0A
     %7D%5D;%0A

Check input from start