trim function

IValidator trim(
  1. IValidator child, {
  2. String? message,
})

Trims leading and trailing whitespace from a string.

Fails if the input value is not a string. Passes the trimmed string to the child validator.

Implementation

IValidator trim(IValidator child, {String? message}) {
  final base = isString() & core.transform((v) => v.trim(), child);
  return core.handleReturnPreserveValue(base, message);
}