Sha256: f9ccf594bbecbd34e3ac6030d6f2c0a55da4d833a23c4f59cf1705dd04315c27
Contents?: true
Size: 744 Bytes
Versions: 1
Compression:
Stored size: 744 Bytes
Contents
require 'valcro/error' require 'valcro/error_list' require 'valcro/runner' module Valcro def self.included(base) base.extend ClassMethods end def errors @error_list ||= Valcro::ErrorList.new end def valid? !errors.any? end def error_messages errors.to_s end def validate errors.clear! self.class.validators.each do |validator_class| validation_runner.add_validator validator_class.new(self) end validation_runner.validate end def validation_runner @validation_runner ||= Valcro::Runner.new(errors) end module ClassMethods def validates_with(validator_class) validators << validator_class end def validators @validators ||= [] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
valcro-0.0.2 | lib/valcro.rb |