module Sequel::Plugins::ValidationHelpersBlock

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

Public Class Methods

apply(model) click to toggle source

Require the validation_helpers plugin

   # File lib/sequel/plugins/validation_helpers_block.rb
30 def self.apply(model)
31   model.plugin(:validation_helpers)
32 end