(startsWith: string, annotations?: Annotations.Filter)
| 7295 | * @since 4.0.0 |
| 7296 | */ |
| 7297 | export function isStartingWith(startsWith: string, annotations?: Annotations.Filter) { |
| 7298 | const formatted = JSON.stringify(startsWith) |
| 7299 | const regExp = new globalThis.RegExp(`^${RegExp_.escape(startsWith)}`) |
| 7300 | const jsonSchemaLiteral = startsWith.replace(/[\uD800-\uDBFF]$/, "") |
| 7301 | return makeFilter( |
| 7302 | (s: string) => s.startsWith(startsWith), |
| 7303 | { |
| 7304 | expected: `a string starting with ${formatted}`, |
| 7305 | representation: { |
| 7306 | id: "effect/schema/isStartingWith", |
| 7307 | payload: { startsWith } |
| 7308 | }, |
| 7309 | toJsonSchema: () => literalToJsonSchema(jsonSchemaLiteral, startsWith, `^${RegExp_.escape(jsonSchemaLiteral)}`), |
| 7310 | arbitraryConstraint: { |
| 7311 | patterns: [{ source: regExp.source, flags: regExp.flags }] |
| 7312 | }, |
| 7313 | ...annotations |
| 7314 | } |
| 7315 | ) |
| 7316 | } |
| 7317 | /** |
| 7318 | * Validates at runtime that a string ends with the specified literal suffix. |
| 7319 | * |
nothing calls this directly
no test coverage detected