From b44fd20e33256475c4e932acce771f0172758030 Mon Sep 17 00:00:00 2001 From: Aaron Yarborough Date: Wed, 15 Jan 2025 12:02:55 +0000 Subject: [PATCH] feat: look for email and phone number for contact --- package-lock.json | 2 ++ validators.js | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index de22509..52f8df8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,12 @@ { "name": "or-uk-data-quality-checker", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "or-uk-data-quality-checker", + "version": "1.0.0", "dependencies": { "commander": "^12.1.0" } diff --git a/validators.js b/validators.js index f8bf3da..f0e1a36 100644 --- a/validators.js +++ b/validators.js @@ -1,5 +1,7 @@ -const hasValidId = (s) => - /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i.test(s.id.trim()); +// const hasValidId = (s) => +// /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i.test(s.id.trim()); + +const hasValidId = (s) => !!s.id?.trim(); const hasValidName = (s) => typeof s.name === "string" && s.name.length > 0; @@ -16,7 +18,10 @@ const hasValidUrl = (s) => { const hasValidOrganisation = (s) => !!s.organization?.id && !!s.organization?.name; -const hasValidContact = (s) => !!s.email?.length > 0; +const hasValidContact = (s) => + s.email?.length > 0 || + (s.contacts?.[0]?.phones?.some(x => !!x.number) ?? false); + const hasValidStatus = (s) => s.status === "active";