(field: D)
| 368 | |
| 369 | /** @internal */ |
| 370 | export const discriminatorStartsWith = <D extends string>(field: D) => |
| 371 | < |
| 372 | R, |
| 373 | P extends string, |
| 374 | Ret, |
| 375 | Fn extends (_: Extract<R, Record<D, `${P}${string}`>>) => Ret |
| 376 | >( |
| 377 | pattern: P, |
| 378 | f: Fn |
| 379 | ) => { |
| 380 | const pred = (_: any) => _ != null && typeof _[field] === "string" && _[field].startsWith(pattern) |
| 381 | |
| 382 | return <I, F, A, Pr>( |
| 383 | self: Matcher<I, F, R, A, Pr, Ret> |
| 384 | ): Matcher< |
| 385 | I, |
| 386 | Types.AddWithout<F, Extract<R, Record<D, `${P}${string}`>>>, |
| 387 | Types.ApplyFilters< |
| 388 | I, |
| 389 | Types.AddWithout<F, Extract<R, Record<D, `${P}${string}`>>> |
| 390 | >, |
| 391 | A | ReturnType<Fn>, |
| 392 | Pr, |
| 393 | Ret |
| 394 | > => (self as any).add(makeWhen(pred, f as any)) as any |
| 395 | } |
| 396 | |
| 397 | /** @internal */ |
| 398 | export const discriminators = <D extends string>(field: D) => |
no test coverage detected