API reference › @evolu/common › Type › int
const int: BrandFactory<"Int", number, IntError>;
Defined in: packages/common/src/Type.ts:6608
Safe integer Brand.
Requires a Number to be an integer within JavaScript's safe integer range.
Example
import {
assertEqual,
assertErr,
assertOk,
assertType,
Data,
Number,
int,
type Brand,
} from "@evolu/common";
const Int = int(Number);
type Int = typeof Int.Output;
assertType<number & Brand<"Int">, Int>();
assertOk(Int.fromUnknown(42), 42);
const invalid = Int.fromUnknown(1.5);
assertErr(invalid);
assertType(Data, invalid.error);
const error: Data = invalid.error;
assertEqual(error, { type: "Int", value: 1.5 });