Class: Castkit::Validators::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/castkit/validators/base.rb

Overview

This class is abstract.

Subclasses must implement #call.

Abstract base class for all attribute validators.

Validators are responsible for enforcing value constraints (e.g., type checks, format rules, numerical bounds). All validators must inherit from this base class and implement the #call instance method.

Supports both instance-level and class-level invocation via .call.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(value, options:, context:) ⇒ void

This method returns an undefined value.

Entry point for validating a value using the validator class.

Instantiates the validator and invokes #call with the provided arguments.

Raises:



25
26
27
# File 'lib/castkit/validators/base.rb', line 25

def call(value, options:, context:)
  new.call(value, options: options, context: context)
end

Instance Method Details

#call(value, options:, context:) ⇒ void

This method is abstract.

This method returns an undefined value.

Validates the value.

Raises:

  • (NotImplementedError)

    if not implemented in subclass



38
39
40
# File 'lib/castkit/validators/base.rb', line 38

def call(value, options:, context:)
  raise NotImplementedError, "#{self.class.name} must implement `#call`"
end