aselab / scala-activerecord

ActiveRecord-like ORM library for Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@Required Validator only applies to String type

nrmitchi opened this issue · comments

As stated in the documentation, the @required validator only checks for "null or empty or white space only string".

It seems to me that this validator should also check Option[_] for "None", however it does not seem to.

I think Option[_] should not be a required value.
Do you have any use case to do so?

How would you go about making an Int required then?

When reading from a JSON, you have to read it as an Option, else your model's Read could be throwing errors for missing fields. It seems that it is a better approach to read fields as Options, and then catch non-existance in the validation.

It's available in version 0.2.4-SNAPSHOT.
But I believe that there will be better solutions for it.