(endsWith: string, annotations?: Annotations.Filter)
| 7277 | * @since 4.0.0 |
| 7278 | */ |
| 7279 | export 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. |
no test coverage detected