Editor NodeJS unique validator.
Editor NodeJS unique validator.
naspersgasp
Posts: 53Questions: 14Answers: 1
in General
Hi,
Good day.
I've only found examples dealing with other SDKs and not NodeJS. Also checked the examples in the NodeJS server package.
What I have tried so far:
.fields(
new Field('Ingredients.Ingredient').validator(Validate.notEmpty())
.validator(Validate.unique())
)
and:
.fields(
new Field('Ingredients.Ingredient').validator(Validate.notEmpty())
.validator(Validate.dbUnique())
)
No luck. I get the following errors:
(node:44680) UnhandledPromiseRejectionWarning: TypeError: Validate.unique is not a function
and:
(node:44653) UnhandledPromiseRejectionWarning: TypeError: host.db(...) is not a function
Could you please assist me with an example? Thanks.
Regards.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Apologies - a few bugs here...
Firstly, the documentation should refer to
dbUnique()
for the NodeJS libraries. There is noValidate.unique()
method there.Secondly, there is a bug in how the database is checked. I've committed a fix and it will ship in 1.8 which isn't that far away (next week).
Until then, you can make those changes locally, or grab the latest source from github.
Regards,
Allan
Once again, thanks allan. Will get the fix. Regards.
Line 603:
should be:
Regards.
Yup - I spotted that one too! Its in the commit above.
Thanks!
Allan