-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add ExtractFormValues type (#45)
- add ExtractFormValues type - make FormSchema into nominal type Co-authored-by: Mikołaj Klaman <mklaman@virtuslab.com>
- Loading branch information
Showing
9 changed files
with
39 additions
and
13 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import { Nominal } from "../../utils"; | ||
|
||
import { GenericFieldDescriptor } from "./field-descriptor"; | ||
|
||
/** | ||
* Description of a form. | ||
* Used to interact with Formts API and point to specific form fields. | ||
*/ | ||
export type FormSchema<Values extends object, Err> = { | ||
readonly [K in keyof Values]: GenericFieldDescriptor<Values[K], Err>; | ||
}; | ||
export type FormSchema<Values extends object, Err> = Nominal<"FormSchema"> & | ||
{ | ||
readonly [K in keyof Values]: GenericFieldDescriptor<Values[K], Err>; | ||
}; | ||
|
||
export type ExtractFormValues<Schema> = Schema extends FormSchema<infer V, any> | ||
? V | ||
: never; |
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