Effect-TS / schema

Modeling the schema of data structures as first-class values

Home Page:https://effect.website

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trimmed is considering a linebreak in the middle of the string as invalid

canastro opened this issue Β· comments

πŸ› Bug report

Current Behavior

S.trimmed is considering a string with a line break in the middle as invalid.

Screen.Recording.2023-07-19.at.10.20.56.mov

Expected behavior

Trimmed should only be invalid when theres empty spaces at the start or end of a string.

Reproducible example

For this particular field I'm using the following schema:

pipe(
  S.string,
  S.message(() => 'common.error_required_field'),
  S.nonEmpty({ message: () => 'common.error_required_field' }),
  S.maxLength(MAX_OVERVIEW_LENGTH, { message: () => 'common.error_max_length_field' }),
  S.trimmed({ message: () => 'common.error_trimmed_field' })
),

Suggested solution(s)

Additional context

Your environment

Which versions of @effect/schema are affected by this issue? Did this work in previous versions of @effect/schema?

Software Version(s)
@effect/schema 0.29.0
TypeScript 5.0.4