Module: Sequel::Plugins::ValidationHelpersBlock
- Defined in:
- lib/sequel_validation_helpers_block.rb
Overview
The ValidationHelpersBlock plugin allows easy determination of which validation rules apply to a given column, by grouping validations by column instead of by validation type. It is significantly more verbose than the default validation_helpers plugin, but provides a nicer DSL, for example:
class Item < Sequel::Model
plugin :validation_helpers_block
def validate
validates do
name do
presence
max_length 10
end
date do
format %r{\d\d/\d\d/\d\d\d\d}
end
number do
presence
integer
end
end
end
end
Defined Under Namespace
Modules: InstanceMethods Classes: ValidationHelpersAttributesBlock, ValidationHelpersValidationsBlock
Class Method Summary collapse
-
.apply(model) ⇒ Object
Require the validation_helpers plugin.
Class Method Details
.apply(model) ⇒ Object
Require the validation_helpers plugin
30 31 32 |
# File 'lib/sequel_validation_helpers_block.rb', line 30 def self.apply(model) model.plugin(:validation_helpers) end |