vivin / regula

Regula: An annotation-based form-validation framework in Javascript
126 stars 24 forks source link

@Numeric checks @Required and numeric #55

Closed lbain closed 10 years ago

lbain commented 10 years ago

It seems that using @Numeric also makes the field required. I think it would be more flexible for those to be two separate constraints, and for the user to decide if they should use "@Numeric @Required" or just "@Numeric" for optional fields.

vivin commented 10 years ago

You can control this behavior on a per-constraint basis by using the ignoreEmpty parameter (e.g. @Numeric(ignoreEmpty=true), or globally by doing:

regula.configure({
    validateEmptyFields: false
});

I have this in the release notes, but unfortunately I haven't gotten around to updating the documentation! I hope to get to this soon.