A value to be asserted
Optional
errorFactory: ((props: TypeGuardError.IProps) => Error)Custom error factory. Default is TypeGuardError
A TypeGuardError instance with detailed reason
Jeongho Nam - https://github.com/samchon
Assertion guard of a value type.
Asserts a parametric value type and throws a TypeGuardError with detailed
reason, if the parametric value is not following the type T
. Otherwise, the
value is following the type T
, nothing would be returned, but the input value
would be automatically casted to the type T
. This is the concept of
"Assertion Guard" of a value type.
If what you want is not asserting but just knowing whether the parametric value is
following the type T
or not, you can choose the is function instead.
Otherwise you want to know all the errors, validate is the way to go.
Also, if you want to returns the parametric value when no problem, you can use
assert function instead.
On the other and, if you don't want to allow any superfluous property that is not
enrolled to the type T
, you can use assertGuardEquals function instead.
A value to be asserted
Optional
errorFactory: ((props: TypeGuardError.IProps) => Error)Custom error factory. Default is TypeGuardError
A TypeGuardError instance with detailed reason
Jeongho Nam - https://github.com/samchon
Assertion guard of a value type.
Asserts a parametric value type and throws a TypeGuardError with detailed reason, if the parametric value is not following the type
T
. Otherwise, the value is following the typeT
, nothing would be returned, but the input value would be automatically casted to the typeT
. This is the concept of "Assertion Guard" of a value type.If what you want is not asserting but just knowing whether the parametric value is following the type
T
or not, you can choose the is function instead. Otherwise you want to know all the errors, validate is the way to go. Also, if you want to returns the parametric value when no problem, you can use assert function instead.On the other and, if you don't want to allow any superfluous property that is not enrolled to the type
T
, you can use assertGuardEquals function instead.