Skip to content

Commit d3008e4

Browse files
author
Sascha Goldhofer
committed
change: email, date, date-time and time validation to validate empty strings
1 parent c08561e commit d3008e4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/validation/format.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const formatValidators: Record<
3939
) => undefined | JsonError | JsonError[]
4040
> = {
4141
date: (draft, schema, value, pointer) => {
42-
if (typeof value !== "string") {
42+
if (typeof value !== "string" || value === "") {
4343
return undefined;
4444
}
4545
// https://github.com/cfworker/cfworker/blob/main/packages/json-schema/src/format.ts
@@ -65,7 +65,7 @@ const formatValidators: Record<
6565
},
6666

6767
"date-time": (draft, schema, value, pointer) => {
68-
if (typeof value !== "string") {
68+
if (typeof value !== "string" || value === "") {
6969
return undefined;
7070
}
7171
if (value === "" || isValidDateTime.test(value)) {
@@ -79,7 +79,7 @@ const formatValidators: Record<
7979

8080
email: (draft, schema, value, pointer) => {
8181
// taken from https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
82-
if (typeof value !== "string") {
82+
if (typeof value !== "string" || value === "") {
8383
return undefined;
8484
}
8585
if (value[0] === '"') {
@@ -176,7 +176,7 @@ const formatValidators: Record<
176176
},
177177

178178
time: (draft, schema, value, pointer) => {
179-
if (typeof value !== "string") {
179+
if (typeof value !== "string" || value === "") {
180180
return undefined;
181181
}
182182
// https://github.com/cfworker/cfworker/blob/main/packages/json-schema/src/format.ts

0 commit comments

Comments
 (0)