API Reference / @evolu/common / Type / NumberFromString

Variable: NumberFromString

const NumberFromString: TransformType<BrandType<Type<"Brand", string & Brand<"Trimmed">, string, TrimmedError, string, StringError>, "MinLength1", MinLengthError<1>, 
  | StringError
| TrimmedError>, BrandType<Type<"Number", number, number, NumberError, number, NumberError>, "Finite", FiniteError, NumberError>, NumberFromStringError>;

Defined in: packages/common/src/Type.ts:1957

Transforms a NonEmptyTrimmedString into a FiniteNumber.

Example

NumberFromString.from("42"); // ok(42)
NumberFromString.from("abc"); // err({ type: "NumberFromString", value: "abc" })

Was this page helpful?