trim function

IValidator trim(
  1. IValidator child
)

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) {
  return isString() & transform((v) => v.trim(), child);
}