I'm trying to apply Javalin validation functionalities in my project and I'd like to ask some questions:
JavalinValidation.validate() method is mentioned, but I can't find in version 3.9.0. Am I missing something?text/plain containing the error message. Is there a out-of-the-box way to return a custom json object with additional data (and a custom structure)?I also noticed there's an open issue about some new validation feature (#998). Maybe there is something not well documented related to my questions?
Thanks!
Hi @davioooh,
In Javalin documentation a JavalinValidation.validate() method is mentioned, but I can't find in version 3.9.0. Am I missing something?
The JavalinValidation.validate() method is from 2.X, I'll fix the docs.
By default a validation error response has a payload of type text/plain containing the error message. Is there a out-of-the-box way to return a custom json object with additional data (and a custom structure)?
In your browser, or in postman? It should return JSON by default if the client asks for JSON. You can collect the errors manually, as shown here: https://javalin.io/documentation#validator-error-collection
If I should to implement it by myself, could it be a helpful feature to add to the project?
All PRs will be considered :)
I've removed the outdated info from the docs now.
In your browser, or in postman? It should return JSON by default if the client asks for JSON.
I'm using Postman for my tests. Sorry, you're right: adding the Accept header to the request I'm a getting a JSON representation.
OK, I'll work on it and if the result worth sharing I'll consider opening a PR.
Thank you very much. :)