Skip to content

Commit ec7c3a4

Browse files
authored
Version 1.1.23 (#1575)
* Revert Email and IdnEmail * ChangeLog * Version
1 parent 6be5bef commit ec7c3a4

11 files changed

Lines changed: 157 additions & 82 deletions

File tree

changelog/1.1.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
---
44

55
### Version Updates
6+
- [Revision 1.1.23](https://github.com/sinclairzx81/typebox/pull/1575)
7+
- Revert Email and IdnEmail
68
- [Revision 1.1.22](https://github.com/sinclairzx81/typebox/pull/1573)
79
- Include Support for 0.x Array Convert
810
- [Revision 1.1.21](https://github.com/sinclairzx81/typebox/pull/1572)

design/website/docs/schema/6_specification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The following optional keywords, formats and proposals are also supported.
7474
| format/date-time ||||||||
7575
| format/duration | - | - | - | - ||||
7676
| format/ecmascript-regex | 1/2 | - | - | - | - | 0/1 | 0/1 |
77-
| format/email |||||| | |
77+
| format/email |||||| 22/27 | 22/27 |
7878
| format/host-name | 2/12 | - | - | - | - | - | - |
7979
| format/hostname | - | 27/28 | 27/28 |||||
8080
| format/idn-email | - | - | - |||||

docs/docs/schema/6_specification.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,8 @@ <h2>Optional Keywords, Formats and Proposals</h2>
628628
<td align="left"></td>
629629
<td align="left"></td>
630630
<td align="left"></td>
631-
<td align="left"></td>
632-
<td align="left"></td>
631+
<td align="left">22/27</td>
632+
<td align="left">22/27</td>
633633
</tr>
634634
<tr>
635635
<td align="left">format/host-name</td>

src/format/email.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,12 @@ THE SOFTWARE.
2626
2727
---------------------------------------------------------------------------*/
2828

29-
import { IsIPv4Internal } from './ipv4.ts'
29+
const Email = /^(?!.*\.\.)[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i
3030

3131
/**
3232
* Returns true if the value is an Email
33-
* @specification Json Schema 2020-12
33+
* @specification ajv-formats
3434
*/
3535
export function IsEmail(value: string): boolean {
36-
const dot = value.indexOf('.')
37-
const at = value.indexOf('@')
38-
const quoted = value[0] === '"' && value[at - 1] === '"'
39-
const ipLiteral = value[at + 1] === '[' && value[value.length - 1] === ']'
40-
const ipv6 = ipLiteral && value.indexOf(':', at) !== -1
41-
const ipv4 = ipLiteral && !ipv6 && IsIPv4Internal(value, at + 2, value.length - 1)
42-
return (at > 0 && at < value.length - 1) &&
43-
!(
44-
// .test@example.com
45-
(!quoted && dot === 0) ||
46-
// te..st@example.com
47-
(!quoted && dot !== -1 && value.indexOf('.', dot + 1) === dot + 1) ||
48-
// test.@example.com
49-
(dot !== -1 && value.indexOf('@', dot) === dot + 1) ||
50-
// joe bloggs@example.com
51-
(!quoted && value.indexOf(' ') !== -1) ||
52-
// user1@oceania.org, user2@oceania.org
53-
(value.indexOf(',') !== -1) ||
54-
// joe.bloggs@[127.0.0.300]
55-
(ipLiteral && !ipv4 && !ipv6) ||
56-
// joe.bloggs@invalid=domain.com
57-
(value.indexOf('=', at) !== -1)
58-
)
36+
return Email.test(value)
5937
}

src/format/idn-email.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ THE SOFTWARE.
2626
2727
---------------------------------------------------------------------------*/
2828

29-
import { IsEmail } from './email.ts'
29+
const IdnEmail = /^(?!.*\.\.)[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+(?:\.[\p{L}\p{N}!#$%&'*+/=?^_`{|}~-]+)*@[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?(?:\.[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?)*$/iu
3030

3131
/**
3232
* Returns true if the value is an IdnEmail
33-
* @specification Json Schema 2020-12
33+
* @specification ajv-formats (unicode-extension)
3434
*/
3535
export function IsIdnEmail(value: string): boolean {
36-
return IsEmail(value)
36+
return IdnEmail.test(value)
3737
}

tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Metrics } from './task/metrics/index.ts'
99
import { Spec } from './task/spec/index.ts'
1010
import { Task } from 'tasksmith'
1111

12-
const Version = '1.1.22'
12+
const Version = '1.1.23'
1313

1414
// ------------------------------------------------------------------
1515
// Build
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
"description": "validation of e-mail addresses",
4+
"schema": {
5+
"$schema": "https://json-schema.org/draft/2020-12/schema",
6+
"format": "email"
7+
},
8+
"tests": [
9+
{
10+
"description": "a quoted string with a space in the local part is valid",
11+
"data": "\"joe bloggs\"@example.com",
12+
"valid": true
13+
},
14+
{
15+
"description": "a quoted string with a double dot in the local part is valid",
16+
"data": "\"joe..bloggs\"@example.com",
17+
"valid": true
18+
},
19+
{
20+
"description": "a quoted string with a @ in the local part is valid",
21+
"data": "\"joe@bloggs\"@example.com",
22+
"valid": true
23+
},
24+
{
25+
"description": "an IPv4-address-literal after the @ is valid",
26+
"data": "joe.bloggs@[127.0.0.1]",
27+
"valid": true
28+
},
29+
{
30+
"description": "an IPv6-address-literal after the @ is valid",
31+
"data": "joe.bloggs@[IPv6:::1]",
32+
"valid": true
33+
}
34+
]
35+
}
36+
]

test/jsonschema/cases/draft2020-12/optional/format/email.json

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,6 @@
6161
"data": "test~@example.com",
6262
"valid": true
6363
},
64-
{
65-
"description": "a quoted string with a space in the local part is valid",
66-
"data": "\"joe bloggs\"@example.com",
67-
"valid": true
68-
},
69-
{
70-
"description": "a quoted string with a double dot in the local part is valid",
71-
"data": "\"joe..bloggs\"@example.com",
72-
"valid": true
73-
},
74-
{
75-
"description": "a quoted string with a @ in the local part is valid",
76-
"data": "\"joe@bloggs\"@example.com",
77-
"valid": true
78-
},
79-
{
80-
"description": "an IPv4-address-literal after the @ is valid",
81-
"data": "joe.bloggs@[127.0.0.1]",
82-
"valid": true
83-
},
84-
{
85-
"description": "an IPv6-address-literal after the @ is valid",
86-
"data": "joe.bloggs@[IPv6:::1]",
87-
"valid": true
88-
},
8964
{
9065
"description": "dot before local part is not valid",
9166
"data": ".test@example.com",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
"description": "validation of e-mail addresses",
4+
"schema": {
5+
"$schema": "https://json-schema.org/v1",
6+
"format": "email"
7+
},
8+
"tests": [
9+
{
10+
"description": "a quoted string with a space in the local part is valid",
11+
"data": "\"joe bloggs\"@example.com",
12+
"valid": true
13+
},
14+
{
15+
"description": "a quoted string with a double dot in the local part is valid",
16+
"data": "\"joe..bloggs\"@example.com",
17+
"valid": true
18+
},
19+
{
20+
"description": "a quoted string with a @ in the local part is valid",
21+
"data": "\"joe@bloggs\"@example.com",
22+
"valid": true
23+
},
24+
{
25+
"description": "an IPv4-address-literal after the @ is valid",
26+
"data": "joe.bloggs@[127.0.0.1]",
27+
"valid": true
28+
},
29+
{
30+
"description": "an IPv6-address-literal after the @ is valid",
31+
"data": "joe.bloggs@[IPv6:::1]",
32+
"valid": true
33+
}
34+
]
35+
}
36+
]

test/jsonschema/cases/v1/format/email.json

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,6 @@
6161
"data": "test~@example.com",
6262
"valid": true
6363
},
64-
{
65-
"description": "a quoted string with a space in the local part is valid",
66-
"data": "\"joe bloggs\"@example.com",
67-
"valid": true
68-
},
69-
{
70-
"description": "a quoted string with a double dot in the local part is valid",
71-
"data": "\"joe..bloggs\"@example.com",
72-
"valid": true
73-
},
74-
{
75-
"description": "a quoted string with a @ in the local part is valid",
76-
"data": "\"joe@bloggs\"@example.com",
77-
"valid": true
78-
},
79-
{
80-
"description": "an IPv4-address-literal after the @ is valid",
81-
"data": "joe.bloggs@[127.0.0.1]",
82-
"valid": true
83-
},
84-
{
85-
"description": "an IPv6-address-literal after the @ is valid",
86-
"data": "joe.bloggs@[IPv6:::1]",
87-
"valid": true
88-
},
8964
{
9065
"description": "dot before local part is not valid",
9166
"data": ".test@example.com",

0 commit comments

Comments
 (0)