Skip to content

trim ​

Removes whitespace from both ends of the string. The result goes to data.

Signature ​

ts
function trim(): Action<string>

Notes ​

  • Order matters: put trim() before length checks.
  • A whitespace-only string becomes '' after trim(), but there is no required error — the emptiness check has already passed. Add minLength(1).

Example ​

Name ​

ts
pipe(string(), trim(), minLength(1, 'Please enter your name'))

See also ​