Class: Dry::Validation::Rust::MessageBackend

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/validation/rust/message_backend.rb

Overview

Adapter interface for resolving localized schema error messages.

Custom backends must inherit from this class and implement #message.

Direct Known Subclasses

I18nBackend, YamlBackend

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ MessageBackend

Creates a backend using the schema message configuration.

Parameters:



15
# File 'lib/dry/validation/rust/message_backend.rb', line 15

def initialize(config); end

Instance Method Details

#message(code:, predicate:, args:, type:, fallback:) ⇒ String

Resolves text for a schema error.

Parameters:

  • code (Symbol)

    the error code.

  • predicate (Symbol, nil)

    the predicate name, without or with a trailing ?.

  • args (Array)

    predicate arguments.

  • type (Symbol, nil)

    the normalized field type.

  • fallback (String)

    message used when no translation is available.

Returns:

  • (String)

    the error message text.

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/dry/validation/rust/message_backend.rb', line 25

def message(code:, predicate:, args:, type:, fallback:)
  raise NotImplementedError, "#{self.class} must implement #message"
end