Use locales for acceptance macro message
This commit is contained in:
parent
269204ea0a
commit
768edb2c06
|
@ -0,0 +1,4 @@
|
|||
en:
|
||||
dry_validation:
|
||||
errors:
|
||||
acceptance: "must accept %{key}"
|
|
@ -55,6 +55,7 @@ module Dry
|
|||
extend ClassInterface
|
||||
|
||||
config.messages.top_namespace = 'dry_validation'
|
||||
config.messages.load_paths << Pathname(__FILE__).join('../../../../config/errors.yml').realpath
|
||||
|
||||
# @!attribute [r] config
|
||||
# @return [Config]
|
||||
|
|
|
@ -9,8 +9,10 @@ module Dry
|
|||
module RuleMethods
|
||||
# @api public
|
||||
def acceptance
|
||||
key_name = keys[0]
|
||||
|
||||
@block = proc do
|
||||
key.failure('must accept terms') unless values[keys[0]].equal?(true)
|
||||
key.failure(:acceptance, key: key_name) unless values[key_name].equal?(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue