An instance of the class type, which serialises itself. The data bag
holds the value an instance's toValue() returned, and a request of this
type receives what type.fromValue makes from it, so a step can be given
an instance with its methods while the data bag holds only plain data.
The check accepts any value: whether fromValue can make an instance from
it is up to fromValue. The type this schema checks for the compiler is
the instance's, since that is what a request receives.
staticfromValue(value: PlainValue): Payment { if (typeofvalue !== "number") { thrownewTypeError("a payment is a number of cents"); } returnnewPayment(value); }
An instance of the class
type, which serialises itself. The data bag holds the value an instance'stoValue()returned, and a request of this type receives whattype.fromValuemakes from it, so a step can be given an instance with its methods while the data bag holds only plain data.The check accepts any value: whether
fromValuecan make an instance from it is up tofromValue. The type this schema checks for the compiler is the instance's, since that is what a request receives.