Module: Hanami::Validations::Predicates

Defined in:
gems/gems/hanami-validations-1.3.4/lib/hanami/validations/predicates.rb,
gems/gems/hanami-validations-1.3.5/lib/hanami/validations/predicates.rb

Overview

Mixin to include when defining shared predicates

Examples:

Inline Predicate

require 'hanami/validations'

module MySharedPredicates
  include Hanami::Validations::Predicates

  predicate :foo? do |actual|
    actual == 'foo'
  end
end

class MyValidator
  include Hanami::Validations
  predicates MySharedPredicates

  validations do
    required(:name).filled(:foo?)
  end
end

See Also:

Since:

  • 0.6.0