What is the best way to override Loopback validation?

1,298 views
Skip to first unread message

Alberto Leal

unread,
Jun 17, 2014, 10:39:42 AM6/17/14
to loopbackjs
Hi guys,

we've been working on a project which adds jsonschema support to loopback -- check this out at http://github.com/globocom/loopback-jsonschema

And, at this moment, we're trying to add support to validations(https://github.com/natesilva/jayschema). I was thinking to use any kind of hook, such as beforeValidate or afterValidate, to call a custom class responsible to validate the data sent.

Taking a look at the Loopback internals, I could return an instance of ValidationError: 

callback(new ValidationError(obj), obj);

so, I don't need to handle the output. Loopback does it already for me.

But, it seems I don't have access to any callback inside the hooks. What do you suggest us to do in this scenario?

thanks a lot,
Alberto



--
Alberto Leal
@albertoleal

Psi

unread,
Jan 30, 2015, 6:37:06 AM1/30/15
to loopb...@googlegroups.com, albe...@gmail.com
Hi Alberto,

i came up with this solution:

https://github.com/psi-4ward/anguloop-example/blob/master/packages/socket-test/loopback/models/car.json

I looked into your module, interesting idea but if i have dynamic Models i would need some dynamic frontend-generation too.

Steeve Fong

unread,
Feb 26, 2015, 11:07:45 AM2/26/15
to loopb...@googlegroups.com, albe...@gmail.com
Hi Psi,

Github links are dead. Do you have another link for as example?

Thanks,
Steeve

Christoph

unread,
Feb 26, 2015, 11:27:46 AM2/26/15
to loopb...@googlegroups.com
--
You received this message because you are subscribed to a topic in the Google Groups "LoopbackJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/loopbackjs/fKiILXuG5Yk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages