Skip to content

Commit 040bf01

Browse files
author
Sascha Goldhofer
committed
release: bump version to v9.1.0
1 parent 6f16346 commit 040bf01

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

dist/jsonSchemaLibrary.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/module/lib/validation/format.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable max-len, no-control-regex */
22
import errors from "./errors";
33
import validUrl from "valid-url";
4+
import { parse as parseIdnEmail } from "smtp-address-parser";
45
// referenced
56
// https://github.com/cfworker/cfworker/blob/main/packages/json-schema/src/format.ts
67
// https://gist.github.com/marcelotmelo/b67f58a08bee6c2468f8
@@ -55,10 +56,10 @@ const formatValidators = {
5556
return errors.formatDateTimeError({ value, pointer, schema });
5657
},
5758
email: (draft, schema, value, pointer) => {
58-
// taken from https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
5959
if (typeof value !== "string" || value === "") {
6060
return undefined;
6161
}
62+
// taken from https://github.com/ExodusMovement/schemasafe/blob/master/src/formats.js
6263
if (value[0] === '"') {
6364
return errors.formatEmailError({ value, pointer, schema });
6465
}
@@ -77,6 +78,22 @@ const formatValidators = {
7778
}
7879
return undefined;
7980
},
81+
/**
82+
* @draft 7
83+
* [RFC6531] https://json-schema.org/draft-07/json-schema-validation.html#RFC6531
84+
*/
85+
"idn-email": (draft, schema, value, pointer) => {
86+
if (typeof value !== "string" || value === "") {
87+
return undefined;
88+
}
89+
try {
90+
parseIdnEmail(value);
91+
return undefined;
92+
}
93+
catch (e) {
94+
return errors.formatEmailError({ value, pointer, schema });
95+
}
96+
},
8097
hostname: (draft, schema, value, pointer) => {
8198
if (typeof value !== "string") {
8299
return undefined;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-schema-library",
3-
"version": "9.0.3",
3+
"version": "9.1.0",
44
"description": "Customizable and hackable json-validator and json-schema utilities for traversal, data generation and validation",
55
"module": "dist/module/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)