Skip to content
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

Make the SPA show validation errors #50

Open
asishallab opened this issue May 20, 2020 · 1 comment
Open

Make the SPA show validation errors #50

asishallab opened this issue May 20, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@asishallab
Copy link
Member

A validation error from our Data Model validation (AJV or Sequelize itself) shows up in the following format in the response:

{
  "errors": [
    {
      "message": "validation failed",
      "details": [
        {
          "keyword": "maximum",
          "dataPath": ".collected_seeds",
          "schemaPath": "#/properties/collected_seeds/maximum",
          "params": {
            "comparison": "<=",
            "limit": 10,
            "exclusive": false
          },
          "message": "should be <= 10"
        }
      ],
      "path": [
        "addAccession"
      ]
    }
  ],
  "data": null
}

Make sure "global" errors are displayed as normal. Some validation errors are not linked to a specific attribute (field).

Parse the details array to extract the validation errors that are linked to specific fields and display the error message e.g. in red below the input element. Feel free to find a suitable style. See, how material design does this.

Note, that the above dataPath in the validation error tells you which attribute caused it. Use that information to associate the error to the respective attribute (field).

If you need further inspiration, see how it is done in our deprecated Vue.js template views/pages/formElements.ejs.

@asishallab asishallab added the enhancement New feature or request label May 20, 2020
@framirez07
Copy link
Contributor

Already implemented.

Missing: AJV i18n

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

No branches or pull requests

2 participants