Validation hooks

13 views
Skip to first unread message

sck_spb

unread,
Aug 10, 2011, 12:46:01 AM8/10/11
to mongod...@googlegroups.com
Hi all!

What is expected way to perform validation?

Thank you

Alexander Azarov

unread,
Aug 10, 2011, 3:38:36 AM8/10/11
to mongod...@googlegroups.com
Hello,

Can you please be more specific? What's your use case?

Regards,
Alexander

sck_spb

unread,
Aug 10, 2011, 4:11:36 AM8/10/11
to mongod...@googlegroups.com
Thx for response, Alexander.

Consider validating models in bean-validation-style: JSR 303 Hibernate ref impl 
(or something like Django validation / Yii validation).
The naive implementation of such behavior is checking values in "setter" param 
in field definition. But seems to me, it's not the proper way in terms of code reuse
and design overall. 
The generic implementation of such behavior may include composable setters 
for fields (setter as a monadic container)

I may have misreaded something in sources, so my question may be rather 
stupid. If so, apologies 


Alexander Azarov

unread,
Aug 10, 2011, 4:37:58 AM8/10/11
to mongod...@googlegroups.com
mongo-scala-driver has no validation hooks. The only it has is static typing (vs. MongoDB java driver), that's it.

sck_spb

unread,
Aug 10, 2011, 5:45:38 AM8/10/11
to mongod...@googlegroups.com
Suppose you prefer single concern principle compliance of you library, so that
m-s-d is only a statically-typed odm, is it so? btw, static typing is really great, 
as well as mapper facility, that's why i think m-s-d > others.
At the same time, could you, please, give any advice how to deal with validation?
Could extending MongoObjectShape with "validate" method and calling it then
be an option? 

Thank you.  

Dmitry Dobrynin

unread,
Aug 10, 2011, 6:13:50 AM8/10/11
to mongo-scala-driver
Hi

As Alexander said validation is not a concern of mongo-scala-driver.
It deals only with persistence. As an external validator for scala you
can use something like https://github.com/wfaler/recursivity-commons.
I think it is appropriate almost for all needs related to validation.

Best regards,
Dmitry

Jed Wesley-Smith

unread,
Aug 10, 2011, 8:47:07 AM8/10/11
to mongod...@googlegroups.com
for functional validation scalaz is awesome. For instance: https://gist.github.com/970717
Reply all
Reply to author
Forward
0 new messages