Incorrect validation error
nickdbush opened this issue · 2 comments
This has been confusing me for a while now. I pass in an attribute to the insert function (which, in the schema, has a required flag), and this happens:
However, the interesting part comes from the code where I do the actual insertion. The name value is defined (it prints out directly before the insert call) and is a string.
I checked through the source code and validateIfUndefined
is receiving undefined
. I have no idea how this is happening, and only started happening a short period of time ago. Any help would be gratefully received!
.then((hash) => {
console.log(`Name value: ${scraped.info.name}, type: ${typeof scraped.info.name}`);
return User.insert({
name: scraped.info.name,
email: scraped.info.email,
username: username,
hash: hash,
house: scraped.info.house,
year: scraped.info.year,
timetable: scraped.timetable,
}).run()
})
const User = thinky.createModel('User', {
name: type.string().required(),
email: type.string(),
username: type.string().required(),
hash: type.string().required(),
house: type.string(),
year: type.number(),
timetable: type.array().required(),
});
Sorry I couldn't be more specific - I will update you if I discover anything.
It should be added the document is still saved into the database.
OK, I've worked it out - the validation issue was on the response from the server! Should have used new User({ ... }).save()
instead. This still seems counter-intuitive though.