Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aseem2625 opened this issue Jul 5, 2018 · 2 comments
Closed

Comments

@aseem2625
Copy link

aseem2625 commented Jul 5, 2018

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
Copy link
Collaborator

Deprecation notice

This repo is no longer maintained (see also #800)

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

For details please visit json-editor/json-editor#5

@aseem2625
Copy link
Author

Raised here.. json-editor/json-editor#123

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants