Class: Rbdantic::Validators::Types::Number

Inherits:
Base
  • Object
show all
Defined in:
lib/rbdantic/validators/types/number.rb

Overview

Abstract base for numeric validators (Integer, Float)

Direct Known Subclasses

Float, Integer

Constant Summary collapse

FLOAT_TOLERANCE_FACTOR =

Tolerance constants for floating-point comparison

1e-9
MIN_FLOAT_TOLERANCE =
1e-12

Instance Attribute Summary

Attributes inherited from Base

#constraints

Instance Method Summary collapse

Methods inherited from Base

#coerce, #initialize, #validate

Constructor Details

This class inherits a constructor from Rbdantic::Validators::Types::Base

Instance Method Details

#expected_type_nameObject

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/rbdantic/validators/types/number.rb', line 16

def expected_type_name
  raise NotImplementedError
end

#matches_type?Boolean

Returns:

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/rbdantic/validators/types/number.rb', line 12

def matches_type?
  raise NotImplementedError
end

#validate_constraints(value, errors, location, strict: false) ⇒ Object



20
21
22
23
24
# File 'lib/rbdantic/validators/types/number.rb', line 20

def validate_constraints(value, errors, location, strict: false)
  validate_bounds(value, errors, location)
  validate_multiple_of(value, errors, location) if constraints[:multiple_of]
  value
end