| 4491 | * @since 3.10.0 |
| 4492 | */ |
| 4493 | export const includes = <S extends Schema.Any>( |
| 4494 | searchString: string, |
| 4495 | annotations?: Annotations.Filter<Schema.Type<S>> |
| 4496 | ) => |
| 4497 | <A extends string>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> => { |
| 4498 | const formatted = JSON.stringify(searchString) |
| 4499 | return self.pipe( |
| 4500 | filter( |
| 4501 | (a) => a.includes(searchString), |
| 4502 | { |
| 4503 | schemaId: IncludesSchemaId, |
| 4504 | [IncludesSchemaId]: { includes: searchString }, |
| 4505 | title: `includes(${formatted})`, |
| 4506 | description: `a string including ${formatted}`, |
| 4507 | jsonSchema: { pattern: `.*${searchString}.*` }, |
| 4508 | ...annotations |
| 4509 | } |
| 4510 | ) |
| 4511 | ) |
| 4512 | } |
| 4513 | |
| 4514 | /** |
| 4515 | * @category schema id |