toIntStrict function
- IValidator child, {
- String? message,
Strict integer coercion.
Accepts only:
- Existing
intvalues - Strings that are pure base-10 integers (no sign handling beyond leading '-' / '+').
Rejects:
doubleinputs (even if whole, e.g.12.0)- Strings containing decimal points or exponent notation (e.g.
"12.0","1e3").
See also:
Implementation
IValidator toIntStrict(IValidator child, {String? message}) {
final base = ($isInt | $isIntString) &
core.transform((v) {
return switch (v) {
final int n => n,
final String s => int.tryParse(s.trim()),
_ => null,
};
}, child);
return handleReturnPreserveValue(base, message);
}