@run-crank/utilities
Advanced tools
Comparing version 0.4.4 to 0.4.5
@@ -9,5 +9,10 @@ "use strict"; | ||
const DATE_TIME_FORMAT = /\d{4}-\d{2}-\d{2}(?:.?\d{2}:\d{2}:\d{2})?/; | ||
const DATE_FORMAT = /^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/; | ||
const EMAIL_FORMAT = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | ||
const COMPARERS = { | ||
'be': (actual, expected) => { | ||
if (DATE_TIME_FORMAT.test(actual) && DATE_TIME_FORMAT.test(expected) && (DATE_FORMAT.test(actual) || DATE_FORMAT.test(expected))) { | ||
actual = actual.toString().slice(0, 10); | ||
expected = expected.toString().slice(0, 10); | ||
} | ||
if (EMAIL_FORMAT.test(String(actual).toLowerCase()) && EMAIL_FORMAT.test(String(expected).toLowerCase())) { | ||
@@ -20,2 +25,6 @@ actual = actual.toString().toLowerCase(); | ||
'not be': (actual, expected) => { | ||
if (DATE_TIME_FORMAT.test(actual) && DATE_TIME_FORMAT.test(expected) && (DATE_FORMAT.test(actual) || DATE_FORMAT.test(expected))) { | ||
actual = actual.toString().slice(0, 10); | ||
expected = expected.toString().slice(0, 10); | ||
} | ||
if (EMAIL_FORMAT.test(String(actual).toLowerCase()) && EMAIL_FORMAT.test(String(expected).toLowerCase())) { | ||
@@ -22,0 +31,0 @@ actual = actual.toString().toLowerCase(); |
{ | ||
"name": "@run-crank/utilities", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "Utility methods and functionality to be shared across all Cogs written in Typescript.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/run-crank/typescript-cog-utilities#readme", |
19647
315