-
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45c9892
commit 597af57
Showing
3 changed files
with
9 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import type { BaseSchema, Input } from '../../types.ts'; | ||
import type { BaseSchema, Input, ParseInfo } from '../../types.ts'; | ||
|
||
/** | ||
* Checks if the input matches the scheme. By using a type predicate, this | ||
* function can be used as a type guard. | ||
* | ||
* @param schema The schema to be used. | ||
* @param input The input to be tested. | ||
* @param info The optional parse info. | ||
* | ||
* @returns Whether the input matches the scheme. | ||
*/ | ||
export function is<TSchema extends BaseSchema>( | ||
schema: TSchema, | ||
input: unknown | ||
input: unknown, | ||
info?: ParseInfo | ||
): input is Input<TSchema> { | ||
return !schema._parse(input, { abortEarly: true, skipPipe: true }).issues; | ||
return !schema._parse(input, { abortEarly: true, ...info }).issues; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters