- NUMBER_EXPR =
/^\d{1,3}(?:,\d{3})*(?:\.\d+)?$/
- String =
Types::String \
| Types::Decimal.transform(::String) { |v| v.to_s('F') } \
| Types::Numeric.transform(::String, &:to_s)
- Symbol =
Types::Symbol | Types::String.transform(::Symbol, &:to_sym)
- NumberString =
Types::String.match(NUMBER_EXPR)
- CoercibleNumberString =
NumberString.transform(::String) { |v| v.tr(',', '') }
- Numeric =
Types::Numeric | CoercibleNumberString.transform(::Numeric, &:to_f)
- Decimal =
Types::Decimal | \
(Types::Numeric.transform(::String, &:to_s) | CoercibleNumberString) \
.transform(::BigDecimal) { |v| BigDecimal(v) }
- Integer =
Numeric.transform(::Integer, &:to_i)