noir-clojure / lib-noir

A set of libraries for ring apps, including stateful sessions.
Eclipse Public License 1.0
483 stars 47 forks source link

noir.validation.is-email? raises exception with nil input #97

Closed JuneKelly closed 10 years ago

JuneKelly commented 10 years ago

A call to validation.is-email will raise an exception when the input value is nil. This causes problems when using noir.validation to validate inputs to (for example) a restful service, where it is possible for the client to omit fields from the input data. For example:

(rule (has-value? user-email)
      [:user-email "email is required"])
(rule (is-email? user-email)
      [:user-email "email must be a valid email address"])

...would fail and raise an exception if the client had omitted the :user-email key from the supplied data. The expected behaviour should be that if the client failed to supply an email address in their input, that both validation messages would be triggered and the request would carry on as normal.

I will submit a pull request momentarily.

JuneKelly commented 10 years ago

With the pull request merged in and the changes released, this issue can be closed. Thanks for the quick turn-around time.