Open dc-me opened 7 years ago
I have found multiple incompatibility with the sails v1, there is no error.invalidAttributes, and the create method doesn't have meta. which fails to work with the v1.
I am having the same issues. The custom error messages are not attaching to the error object in Sails v1.
Hello,
So will we be getting v1 support or not ?
@danywheeler is correct. It seems that in Sails v1 the format of the errors has been changed dramatically.
{
"code": "E_INVALID_NEW_RECORD",
"details": "New record contains the wrong type of data for property `value`. Specified value is not a valid `value`. 1 error validating value: \n • Specified value (a string: '') doesn't match the expected type: 'number'",
"message": "The server could not fulfill this request (`POST /api/equipment`) 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."
}
Additionally,
WLError no longer exists and instead, Waterline is mostly generating errors through the Flaverr.js library. So that whole piece of code will need to be rethought.
To boot, most validation errors are generated deep inside the Waterline normalization process. And Waterline also tends to give up after the first error detected (often a type error, or required attribute error). Only high level (e.g. minLength, email, etc.) come back with anything like the old array (which is now named ruleViolations).
based on discussions we could not use this hook with v1 of sails :-\ , please add it on docs
sails> Page.create({name:'t'}).exec(console.log)Error (E_UNKNOWN) :: Encountered an unexpected error at new WLError (/Users/dany/Projects/rocket-common-h5/node_modules/sails-hook-validation/node_modules/waterline/lib/waterline/error/WLError.js:26:15) at Object.module.exports.patch (/Users/dany/Projects/rocket-common-h5/node_modules/sails-hook-validation/lib/WLValidationError.js:8:13) at /Users/dany/Projects/rocket-common-h5/nodemodules/sails-hook-validation/lib/create.js:66:48 at .extend._WLModel (/Users/dany/Projects/rocket-common-h5/node_modules/waterline/lib/waterline/methods/create.js:155:20) at parley (/Users/dany/Projects/rocket-common-h5/node_modules/parley/lib/parley.js:111:5) at newConstructor.create (/Users/dany/Projects/rocket-common-h5/node_modules/waterline/lib/waterline/methods/create.js:130:10) at newConstructor.create (/Users/dany/Projects/rocket-common-h5/node_modules/sails-hook-validation/lib/create.js:47:14) at module.exports.Deferred.exec (/Users/dany/Projects/rocket-common-h5/node_modules/sails-hook-validation/node_modules/waterline/lib/waterline/query/deferred.js:477:16) at repl:1:25 at ContextifyScript.Script.runInThisContext (vm.js:50:33) at REPLServer.defaultEval (repl.js:239:29) at bound (domain.js:301:14) at REPLServer.runBound [as eval] (domain.js:314:12) at REPLServer.onLine (repl.js:440:10) at emitOne (events.js:120:20) at REPLServer.emit (events.js:210:7) at REPLServer.Interface._onLine (readline.js:282:10) at REPLServer.Interface._line (readline.js:631:8) at REPLServer.Interface._ttyWrite (readline.js:911:14) at REPLServer.self._ttyWrite (repl.js:509:7) at ReadStream.onkeypress (readline.js:160:10) at emitTwo (events.js:125:13)
is it the waterline's version? because the v1 uses a new one.