Hyperlinkv0.8.0-beta.28

Schema

Schema.isEndsWithfunctioneffect/Schema.ts:6879
(
  endsWith: string,
  annotations?: Annotations.Filter
): SchemaAST.Filter<string>

Validates at runtime that a string ends with the specified literal suffix.

Details

Notes: The JSON Schema and arbitrary metadata are built from ${endsWith}$ without escaping regexp metacharacters. If the suffix contains regexp syntax, generated patterns may not be equivalent to the runtime endsWith check.

String checks
Source effect/Schema.ts:687920 lines
export function isEndsWith(endsWith: string, annotations?: Annotations.Filter) {
  const formatted = JSON.stringify(endsWith)
  return makeFilter(
    (s: string) => s.endsWith(endsWith),
    {
      expected: `a string ending with ${formatted}`,
      meta: {
        _tag: "isEndsWith",
        endsWith,
        regExp: new globalThis.RegExp(`${endsWith}$`)
      },
      arbitrary: {
        constraint: {
          patterns: [`${endsWith}$`]
        }
      },
      ...annotations
    }
  )
}
Referenced by 1 symbols