Module: Jet::Type::JSON

Extended by:
Core::InstanceRegistry
Defined in:
lib/jet/type/json.rb

Defined Under Namespace

Modules: Matcher

Constant Summary collapse

Decimal =
Type.with(HTTP::Decimal) do
  coerce(:before) do
    match(&Matcher::Numeric)
    transform do |input|
      case input
      when ::Float
        BigDecimal(input, ::Float::DIG)
      else
        BigDecimal(input)
      end
    end
  end
end
Float =
Type.with(Strict::Float) do
  coerce do
    match(&Matcher::Numeric)
    transform(&:to_f)
  end
end
Integer =
Type.with(Strict::Integer) do
  coerce do
    match(&Matcher::Numeric)
    transform(&:to_i)
    check(:number_too_precise) { |output, input| input == output }
  end
end