Sha256: 8383c564df9669f37edf17df17a868d57dc3464001dddd72961ab3701843516a
Contents?: true
Size: 668 Bytes
Versions: 1
Compression:
Stored size: 668 Bytes
Contents
# frozen_string_literal: true module Grape module Validations class SameAsValidator < Base def validate_param!(attr_name, params) confirmation = options_key?(:value) ? @option[:value] : @option return if params[attr_name] == params[confirmation] raise Grape::Exceptions::Validation.new( params: [@scope.full_name(attr_name)], message: build_message ) end private def build_message if options_key?(:message) @option[:message] else format I18n.t(:same_as, scope: 'grape.errors.messages'), parameter: @option end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-1.6.0 | lib/grape/validations/validators/same_as.rb |