-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(lib): improve types * chore(lib): correct README
- Loading branch information
Showing
12 changed files
with
113 additions
and
40 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,5 +1,5 @@ | ||
import type { Modifier } from '@/types' | ||
|
||
export const validateModifiers = <T>(value: T, modifiers?: Modifier<T>[]) => { | ||
modifiers?.forEach((arg) => arg.validate(value)) | ||
modifiers?.forEach((modifier) => modifier.validate(value)) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Parser } from '@/types' | ||
|
||
export const isParser = <T>(input: unknown): input is T => { | ||
return input !== null && typeof input === 'object' && 'parse' in input && 'name' in input | ||
} | ||
|
||
export const isParserRecords = <T extends Record<string, Parser<unknown>>>( | ||
input: unknown, | ||
): input is T => | ||
input instanceof Object && | ||
!(input instanceof Array) && | ||
!(input instanceof Boolean) && | ||
!(input instanceof Date) && | ||
!(input instanceof Error) && | ||
!(input instanceof Function) && | ||
!(input instanceof Number) && | ||
!(input instanceof RegExp) && | ||
!(input instanceof String) | ||
// && Object.values(input).every((value) => isParser(value)) | ||
// 'parse' in input && | ||
// 'name' in input |
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
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,5 +1,5 @@ | ||
export { custom, type Custom } from './custom' | ||
export { min, type Min } from './min' | ||
export { max, type Max } from './max' | ||
export { email, type Email } from './email' | ||
export { enumerator, type Enumerator } from './enumerator' | ||
export { max, type Max } from './max' | ||
export { min, type Min } from './min' |
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
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
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