Last active
August 29, 2015 14:09
-
-
Save gotar/15df9116d61f6f13ce09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'lotus/validations' | |
module UserValidations | |
include Lotus::Validations | |
attribute :login, presence: true, format: /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/ | |
attribute :password, presence: true, confirmation: true, size: 8..64 | |
end | |
class User | |
include UserValidations | |
end | |
>> u = User.new({}) | |
=> #<User:0x007fb57b95def8 @attributes={}, @errors=#<Lotus::Validations::Errors:0x007fb57b95dea8 @errors={}>> | |
>> u.valid? | |
NoMethodError: undefined method `attributes' for User:Class | |
from /Users/gotar/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/lotus-validations-0.1.0/lib/lotus/validations.rb:395:in `_attributes' | |
from /Users/gotar/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/lotus-validations-0.1.0/lib/lotus/validations.rb:361:in `valid?' | |
from (irb):2 | |
from /Users/gotar/.rbenv/versions/2.1.5/bin/irb:11:in `<main>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment