Sails version: 1.0.0-45
Node version: 9.5.0
NPM version: 5.6.0
DB adapter name: N/A
DB adapter version: N/A
Operating system: Win7x64
Nowadays validation on model throw error json like this:
code: "E_INVALID_NEW_RECORD"
details: "Missing value for required attribute `name`. Expected a string, but instead, got: undefined"
message: "The server could not fulfill this request (`POST /api/users`) due to a problem with the parameters that were sent. See the `details` for more info. **The following additional tip will not be shown in production**: Tip: Check your client-side code to make sure that the request data it sends matches the expectations of the corresponding attribues in your model. Also check that your client-side code sends data for every required attribute."
It's suck and there's some reasons:
details and look for a field name just to mark field for an user.details.sails-hook-validation module which can set different messages for different validations, nothing (but i18n) more.details: return object instead of string. That object should contain keys which is fields with errors and values - validation error message for custom field:details: {
name: "Field is required"
}
and attributes lookes like this:
attributes: {
name: {
type: 'string',
required: [true, "Field is required"],
minLength: [10, "Name is too short"]
},
...
}
Hi @Iworb! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.
Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.
*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]
ok, fixed!
Hi @Iworb! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.
Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.
*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]
Technically it's not an issue, so there's no way to pass this bot :(
Hi @Iworb! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check.
Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly.
*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]
Hi @mikermcneil! Please is anything going to be done about this? The errors returned by Sails are not user-friendly, and it's difficult to define custom error messages.
@mikermcneil Have we achieved something else about this? Because its really bad to have to parse the string of the validation error, tryng to find what is the attribute that had failed and what rule i should translate to the user? (Our web service is served in PT-BR).