Manually added errors are cleared when calling model.valid?
Closed this issue · 1 comments
adacosta commented
lib/mongomodel/concerns/validations.rb L:19 does an errors.clear, instead of respecting any user added errors. If (in the model) I do an errors.add_to_base or errors.add, my added errors are disregarded when i call model.valid?
spohlenz commented
Try using the validate method. e.g.
validate :sufficient_funds
def sufficient_funds
errors.add_to_base("Insufficient funds") if balance.zero?
end