-
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(validators): add built-in validation rules (#27)
- export validation rules under validators namespace - support early abort of validationg by throwing 'true' Co-authored-by: Mikołaj Klaman <mklaman@virtuslab.com>
- Loading branch information
Showing
10 changed files
with
655 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export { createForm } from "./builders"; | ||
export { useFormts } from "./hooks/use-formts"; | ||
export { useFormts, FormtsOptions } from "./hooks/use-formts"; | ||
|
||
export { FieldDecoder } from "./types/field-decoder"; | ||
export { FieldDescriptor } from "./types/field-descriptor"; | ||
export { FormSchema } from "./types/form-schema"; | ||
export { FormValidator, Validator } from "./types/form-validator"; |
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 +1,2 @@ | ||
export * from "./core"; | ||
export * from "./validators"; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Primitive } from "../utils/utility-types"; | ||
|
||
export type Required = { code: "required" }; | ||
export type OneOf = { code: "oneOf"; allowedValues: Primitive[] }; | ||
|
||
export type Integer = { code: "integer" }; | ||
export type MinValue = { code: "minValue"; min: number }; | ||
export type MaxValue = { code: "maxValue"; max: number }; | ||
export type GreaterThan = { code: "greaterThan"; threshold: number }; | ||
export type LesserThan = { code: "lesserThan"; threshold: number }; | ||
|
||
export type Pattern = { code: "pattern"; regex: RegExp }; | ||
export type HasSpecialChar = { code: "hasSpecialChar" }; | ||
export type HasUpperCaseChar = { code: "hasUpperCaseChar" }; | ||
export type HasLowerCaseChar = { code: "hasLowerCaseChar" }; | ||
|
||
export type MinLength = { code: "minLength"; min: number }; | ||
export type MaxLength = { code: "maxLength"; max: number }; | ||
export type ExactLength = { code: "exactLength"; expected: number }; | ||
|
||
export type ValidDate = { code: "validDate" }; | ||
export type MinDate = { code: "minDate"; min: Date }; | ||
export type MaxDate = { code: "maxDate"; max: Date }; |
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,4 @@ | ||
// TODO: tree-shaking compatible way of importing validators | ||
export * as validators from "./validators"; | ||
|
||
export * as BaseErrors from "./base-errors"; |
Oops, something went wrong.