jdorn / json-editor

JSON Schema Based Editor
MIT License
5.8k stars 1.08k forks source link

Custom validations working but select is not showing errors in DOM. #819

Closed aseem2625 closed 6 years ago

aseem2625 commented 6 years ago

Property is defined as:

    "location": {
      "type": "string",
      "title": "Location",
      "enum": [
        null,
          "city1",
          "city2",
          "city3",
      ],
      "options": {
        "enum_titles": [
          "--Select--",
          "city1",
          "city2",
          "city3",
        ]
      }
    }

Custom validation added using:

JSONEditor.defaults.custom_validators.push(function(schema, value, path) {
var errors = [];
if(some_condition) {
    errors.push({
        path: path,
        property: 'format',
        message: 'Some custom message on select'
    });
}

return errors
});

On var errors = editor.validate();, errors correctly contains the error as per the custom validation above, however, just for the Select element, has-error class and <p class="help-block errormsg"> are missing from DOM. For custom validators on other type=string fields, everything working fine.

Is there any way to implement this?

schmunk42 commented 6 years ago

Deprecation notice

This repo is no longer maintained (see also https://github.com/jdorn/json-editor/issues/800)

Development is continued at https://github.com/json-editor/json-editor

For details please visit https://github.com/json-editor/json-editor/issues/5

aseem2625 commented 6 years ago

Raised here.. https://github.com/json-editor/json-editor/issues/123

Thanks