Permalink
Browse files

make sure no blanks are in the error message

  • Loading branch information...
1 parent 6e5a9b9 commit d2b5369eaf06ed63b80efcc1549138adc958f661 @dnagir dnagir committed Dec 22, 2011
@@ -33,8 +33,9 @@ class ValidationContext
validator.call(me, me.subject, field, options) if shouldValidate
validatorSubscriber.subscribe (newError) ->
- err = me.subject.errors[field]
- me.subject.errors[field]( [err(), newError].compact().join(", ") )
+ currentError = me.subject.errors[field]
+ actualError = [currentError(), newError].exclude((x) -> !x).join(", ")
+ me.subject.errors[field]( actualError or null)
# Clear the error only once before the value gets changed
validatorSubscriber.subscribe ->
@@ -27,7 +27,7 @@ describe "Validations", ->
it "should remove error when field becomes valid", ->
@subject.name ''
@subject.name 'myself'
- expect(@subject.errors.name()).toBeFalsy()
+ expect(@subject.errors.name()).toBe null
it "should use custom validator", ->
@subject.correct yes

0 comments on commit d2b5369

Please sign in to comment.