toIntSafe function
- IValidator child, {
- String? message,
Safe integer coercion (strict + 53-bit range guard).
Behavior:
- Same accepted forms as toIntStrict.
- Additionally validates that the resulting integer is within the safe
IEEE-754 53-bit signed range (
-9007199254740991, 9007199254740991). This is useful when code may target JavaScript runtimes where larger integers lose precision.
Rejects any value outside that range.
See also:
- toInt – standard coercion (allows doubles)
- toIntStrict – strict without range guard
Implementation
IValidator toIntSafe(IValidator child, {String? message}) {
final base = toIntStrict(isInRange(
_kMinSafeInt,
_kMaxSafeInt,
message: 'a value strictly convertible to an int within safe 53-bit range',
));
return core.handleReturnPreserveValue(base, message);
}