I am trying to validate a valid character with Hanami (which sits on top of dry-validation ).
The point is this: how to check the mapping associated with two fields: email + password?
I read about custom predicates, but they only seem to be for each field. Another concept is the rule, but according to the examples, it does not connect 2 things as I need.
Here is my code:
module Web::Controllers::Sessions
class Create
include Web::Action
expose :validation
def call(params)
@validation = SigninValidator.new(params[:user]).validate
if @validation.success?
end
end
end
class SigninValidator
include Hanami::Validations::Form
validations do
required(:email) { format?(EMAIL_REGEX)}
required(:password).filled(:str?)
end
end
Unfortunately, the validation section in the Hanami manual is empty, and I could not find a solution considering the sources (hanami validation and dry-validation).
Any help would be appreciated.
source
share