From abb01a67c484d9a118c26a3882920b2230d9bb1d Mon Sep 17 00:00:00 2001 From: Mykhailo Temnokhud Date: Thu, 27 Feb 2025 01:49:26 +0100 Subject: [PATCH 1/3] feat: add 'idn-email' format validation --- CHANGELOG.md | 4 ++++ lib/src/json_schema/formats/idn_email_validator.dart | 6 ++++-- pubspec.yaml | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 282db7ce..eb29e0a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.2.1 + +- [Add 'idn-email' format validation]() + ## 5.2.0 - [Avoid unnecessary null pointer exception if reference schema is given](https://github.com/Workiva/json_schema/pull/188) - [Fix ValidationResults.toString().](https://github.com/Workiva/json_schema/pull/189) diff --git a/lib/src/json_schema/formats/idn_email_validator.dart b/lib/src/json_schema/formats/idn_email_validator.dart index 3d73a8a2..b0ba1308 100644 --- a/lib/src/json_schema/formats/idn_email_validator.dart +++ b/lib/src/json_schema/formats/idn_email_validator.dart @@ -1,7 +1,9 @@ import 'package:json_schema/src/json_schema/models/validation_context.dart'; +import 'package:rfc_6531/rfc_6531.dart' as rfc_6531; ValidationContext defaultIdnEmailValidator(ValidationContext context, String instanceData) { - // No maintained dart packages exist to validate RFC6531, - // and it's too complex for a regex, so best effort is to pass for now. + if (rfc_6531.regExp.firstMatch(instanceData) == null) { + context.addError('"idn-email" format not accepted $instanceData'); + } return context; } diff --git a/pubspec.yaml b/pubspec.yaml index 9054b3f1..0c1f7116 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: json_schema -version: 5.2.0 +version: 5.2.1 description: JSON Schema implementation in Dart homepage: https://github.com/workiva/json_schema @@ -10,6 +10,7 @@ dependencies: collection: ^1.15.0 http: ">=0.13.4 <2.0.0" logging: ^1.0.0 + rfc_6531: ^1.0.0 rfc_6901: '>=0.1.0 <0.3.0' uri: '>=0.11.1 <2.0.0' From b13f182d657644307d5fd954b14dfc1e58cfb29a Mon Sep 17 00:00:00 2001 From: Mykhailo Temnokhud Date: Thu, 27 Feb 2025 01:54:34 +0100 Subject: [PATCH 2/3] feat: add GH PR link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb29e0a7..ca922f60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## 5.2.1 -- [Add 'idn-email' format validation]() +- [Add 'idn-email' format validation](https://github.com/Workiva/json_schema/pull/204) ## 5.2.0 - [Avoid unnecessary null pointer exception if reference schema is given](https://github.com/Workiva/json_schema/pull/188) From dfe23345d837498d5fbd909266ca48781c32ca44 Mon Sep 17 00:00:00 2001 From: Mykhailo Temnokhud Date: Fri, 28 Feb 2025 17:39:03 +0100 Subject: [PATCH 3/3] fix: revert changes to versioning --- CHANGELOG.md | 4 ---- pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca922f60..282db7ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,3 @@ -## 5.2.1 - -- [Add 'idn-email' format validation](https://github.com/Workiva/json_schema/pull/204) - ## 5.2.0 - [Avoid unnecessary null pointer exception if reference schema is given](https://github.com/Workiva/json_schema/pull/188) - [Fix ValidationResults.toString().](https://github.com/Workiva/json_schema/pull/189) diff --git a/pubspec.yaml b/pubspec.yaml index 0c1f7116..4589a0b7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: json_schema -version: 5.2.1 +version: 5.2.0 description: JSON Schema implementation in Dart homepage: https://github.com/workiva/json_schema