-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): create schemas for data validation
- Loading branch information
1 parent
9139704
commit 3e8b66b
Showing
2 changed files
with
21 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import * as yup from "yup" | ||
import * as yup from "yup"; | ||
|
||
const AuthorSchema = yup | ||
.object({ | ||
name: yup.string().required().min(1).max(300), | ||
email: yup.string().email().min(1).max(320), | ||
nationality: yup.string().min(1).max(100), | ||
birthDate: yup.string().matches(/^(?:(?:19|20)\d{2})-(?:(?:0[1-9]|1[0-2]))-(?:(?:0[1-9]|[12]\d|3[01]))$/, { message: "Follow the format AAAA-MM-DD" }), | ||
}) | ||
.required() | ||
.object({ | ||
name: yup.string().required().min(1).max(300), | ||
email: yup.string().email().min(1).max(320), | ||
nationality: yup.string().min(1).max(100), | ||
birthDate: yup.string().matches(/^(?:(?:19|20)\d{2})-(?:(?:0[1-9]|1[0-2]))-(?:(?:0[1-9]|[12]\d|3[01]))$/, { | ||
message: "Follow the format AAAA-MM-DD", | ||
}), | ||
}) | ||
.required(); | ||
|
||
|
||
export default AuthorSchema | ||
export default AuthorSchema; |
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,10 @@ | ||
import * as yup from "yup"; | ||
|
||
const BookSchema = yup | ||
.object({ | ||
title: yup.string().min(1).max(300).required(), | ||
pages: yup.number().min(1).required(), | ||
}) | ||
.required(); | ||
|
||
export default BookSchema; |