the type of the value
Creates a value that may be invalid.
true
if the value is valid, or false
if invalid
the value
Consumes the value if it is valid. If the value is invalid, no action is taken.
consumes the value if it is valid
Checks if the value is null.
true
if the value is null
; false
otherwise
Checks if the value is null.
true
if the value is undefined
; false
otherwise
Checks if the value is valid.
true
if the value is valid; false
otherwise
Applies a function to the value if it is valid. If the value is invalid, no action is taken.
the type of value returned by the mapper
this
if the value is invalid; otherwise, a MaybeInvalid
instance wrapping the
result of applying the mapper to the value
Converts an undefined
or null
value to an invalid value. If the value is invalid or non-null
, no
action is taken.
an invalid value if the original value was undefined
or null
; otherwise, returns this
with T
excluding undefined
and null
Evaluates a condition on the value.
the condition to evaluate
true
if the value is invalid, undefined
, null
or if the condition
returns false
;
otherwise, returns false
Static
invalidReturns an invalid value.
the type of the value
an invalid value
Static
validReturns a valid value.
the type of the value
a value
a valid value
Represents a value that is being validated.
This class is not intended to replace
undefined
ornull
references but to record additional information alongside them.Instead of throwing an error when an
undefined
ornull
value is accessed, the system marks it as invalid and continues to record validation failures.