| 4460 | * @since 3.10.0 |
| 4461 | */ |
| 4462 | export const endsWith = <S extends Schema.Any>( |
| 4463 | endsWith: string, |
| 4464 | annotations?: Annotations.Filter<Schema.Type<S>> |
| 4465 | ) => |
| 4466 | <A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => { |
| 4467 | const formatted = JSON.stringify(endsWith) |
| 4468 | return self.pipe( |
| 4469 | filter( |
| 4470 | (a) => a.endsWith(endsWith), |
| 4471 | { |
| 4472 | schemaId: EndsWithSchemaId, |
| 4473 | [EndsWithSchemaId]: { endsWith }, |
| 4474 | title: `endsWith(${formatted})`, |
| 4475 | description: `a string ending with ${formatted}`, |
| 4476 | jsonSchema: { pattern: `^.*${endsWith}$` }, |
| 4477 | ...annotations |
| 4478 | } |
| 4479 | ) |
| 4480 | ) |
| 4481 | } |
| 4482 | |
| 4483 | /** |
| 4484 | * @category schema id |