Hyperlinkv0.8.0-beta.28

Schema

Schema.isTrimmedfunctioneffect/Schema.ts:6540
(annotations?: Annotations.Filter): SchemaAST.Filter<string>

Validates that a string has no leading or trailing whitespace.

Details

JSON Schema:

This check corresponds to a pattern constraint in JSON Schema that matches strings without leading or trailing whitespace.

Arbitrary:

When generating test data with fast-check, this applies a patterns constraint to ensure generated strings match the trimmed pattern.

String checks
Source effect/Schema.ts:654018 lines
export function isTrimmed(annotations?: Annotations.Filter) {
  return makeFilter(
    (s: string) => s.trim() === s,
    {
      expected: "a string with no leading or trailing whitespace",
      meta: {
        _tag: "isTrimmed",
        regExp: new globalThis.RegExp(TRIMMED_PATTERN)
      },
      arbitrary: {
        constraint: {
          patterns: [TRIMMED_PATTERN]
        }
      },
      ...annotations
    }
  )
}
Referenced by 2 symbols