MCPcopy Create free account
hub / github.com/Effect-TS/effect / isEndsWith

Function isEndsWith

packages/effect/src/Schema.ts:7279–7300  ·  view source on GitHub ↗
(endsWith: string, annotations?: Annotations.Filter)

Source from the content-addressed store, hash-verified

7277 * @since 4.0.0
7278 */
7279export function isEndsWith(endsWith: string, annotations?: Annotations.Filter) {
7280 const formatted = JSON.stringify(endsWith)
7281 const regExp = new globalThis.RegExp(`${RegExp_.escape(endsWith)}$`)
7282 return makeFilter(
7283 (s: string) => s.endsWith(endsWith),
7284 {
7285 expected: `a string ending with ${formatted}`,
7286 representation: {
7287 id: "effect/schema/isEndsWith",
7288 payload: { endsWith }
7289 },
7290 toJsonSchema: () => ({ pattern: regExp.source }),
7291 toCode: () => ({ runtime: `Schema.isEndsWith(${format(endsWith)})` }),
7292 arbitrary: {
7293 constraint: {
7294 patterns: [regExp.source]
7295 }
7296 },
7297 ...annotations
7298 }
7299 )
7300}
7301
7302/**
7303 * Reviver for persisted `isEndsWith` checks.

Callers 1

Schema.tsFile · 0.85

Calls 2

formatFunction · 0.90
makeFilterFunction · 0.85

Tested by

no test coverage detected