Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1 from ryantm/master

improve present validation to not assume map value is a string
  • Loading branch information...
commit ef553fbf5e8f28e0857f40c7e53cad180266c54a 2 parents e2ccd8e + 6062018
@logaan authored
Showing with 6 additions and 2 deletions.
  1. +1 −1  src/vlad/validations.clj
  2. +5 −1 test/vlad/test/validations.clj
View
2  src/vlad/validations.clj
@@ -10,7 +10,7 @@
(validate (present :name)
{:name \"Vlad\"})"
[selector]
- (predicate selector str/blank? {:type ::present}))
+ (predicate selector #(if (string? %) (str/blank? %) true) {:type ::present}))
(defn length-over
"Checks that the `count` of the value found at `selector` is over `size`."
View
6 test/vlad/test/validations.clj
@@ -3,12 +3,16 @@
[vlad validations validation-types]))
(tabular
- (fact (validate ?validator {:name "Chris" :confirm_name "Brad"}) => ?errors)
+ (fact (validate ?validator {:name "Chris" :confirm_name "Brad" :number-of-teeth 32}) => ?errors)
?validator ?errors
(present [:name])
[]
+ (present [:number-of-teeth])
+ [{:type :vlad.validations/present
+ :selector [:number-of-teeth]}]
+
(present [:age])
[{:type :vlad.validations/present
:selector [:age]}]
Please sign in to comment.
Something went wrong with that request. Please try again.