Class: Ukiryu::Validation::Constraint Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/ukiryu/validation/constraints.rb

Overview

This class is abstract.

Abstract base class for all constraints

Constraints define validation rules that can be applied to values. Each constraint type encapsulates a specific validation logic.

Instance Method Summary collapse

Instance Method Details

#applies_to?(_context) ⇒ Boolean

Check if this constraint applies to the given context

Parameters:

  • context (Hash)

    validation context

Returns:

  • (Boolean)

    true if constraint should be applied



26
27
28
# File 'lib/ukiryu/validation/constraints.rb', line 26

def applies_to?(_context)
  true
end

#validate(value, context = {}) ⇒ void

This method returns an undefined value.

Validate a value against this constraint

Parameters:

  • value (Object)

    the value to validate

  • context (Hash) (defaults to: {})

    additional context for validation

Raises:

  • (ValidationError)

    if validation fails



18
19
20
# File 'lib/ukiryu/validation/constraints.rb', line 18

def validate(value, context = {})
  raise NotImplementedError, 'Subclasses must implement validate'
end