Aktueller Stand
This commit is contained in:
83
backend/node_modules/ajv-formats/dist/formats.js
generated
vendored
83
backend/node_modules/ajv-formats/dist/formats.js
generated
vendored
@@ -8,8 +8,10 @@ exports.fullFormats = {
|
||||
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
||||
date: fmtDef(date, compareDate),
|
||||
// date-time: http://tools.ietf.org/html/rfc3339#section-5.6
|
||||
time: fmtDef(time, compareTime),
|
||||
"date-time": fmtDef(date_time, compareDateTime),
|
||||
time: fmtDef(getTime(true), compareTime),
|
||||
"date-time": fmtDef(getDateTime(true), compareDateTime),
|
||||
"iso-time": fmtDef(getTime(), compareIsoTime),
|
||||
"iso-date-time": fmtDef(getDateTime(), compareIsoDateTime),
|
||||
// duration: https://tools.ietf.org/html/rfc3339#appendix-A
|
||||
duration: /^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,
|
||||
uri,
|
||||
@@ -22,7 +24,7 @@ exports.fullFormats = {
|
||||
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
|
||||
hostname: /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,
|
||||
// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
|
||||
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
||||
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,
|
||||
ipv6: /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,
|
||||
regex,
|
||||
// uuid: http://tools.ietf.org/html/rfc4122
|
||||
@@ -52,8 +54,10 @@ exports.fullFormats = {
|
||||
exports.fastFormats = {
|
||||
...exports.fullFormats,
|
||||
date: fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d$/, compareDate),
|
||||
time: fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareTime),
|
||||
"date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareDateTime),
|
||||
time: fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareTime),
|
||||
"date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareDateTime),
|
||||
"iso-time": fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoTime),
|
||||
"iso-date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoDateTime),
|
||||
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
|
||||
uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
|
||||
"uri-reference": /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
|
||||
@@ -91,28 +95,47 @@ function compareDate(d1, d2) {
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
const TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
|
||||
function time(str, withTimeZone) {
|
||||
const matches = TIME.exec(str);
|
||||
if (!matches)
|
||||
return false;
|
||||
const hour = +matches[1];
|
||||
const minute = +matches[2];
|
||||
const second = +matches[3];
|
||||
const timeZone = matches[5];
|
||||
return (((hour <= 23 && minute <= 59 && second <= 59) ||
|
||||
(hour === 23 && minute === 59 && second === 60)) &&
|
||||
(!withTimeZone || timeZone !== ""));
|
||||
const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
|
||||
function getTime(strictTimeZone) {
|
||||
return function time(str) {
|
||||
const matches = TIME.exec(str);
|
||||
if (!matches)
|
||||
return false;
|
||||
const hr = +matches[1];
|
||||
const min = +matches[2];
|
||||
const sec = +matches[3];
|
||||
const tz = matches[4];
|
||||
const tzSign = matches[5] === "-" ? -1 : 1;
|
||||
const tzH = +(matches[6] || 0);
|
||||
const tzM = +(matches[7] || 0);
|
||||
if (tzH > 23 || tzM > 59 || (strictTimeZone && !tz))
|
||||
return false;
|
||||
if (hr <= 23 && min <= 59 && sec < 60)
|
||||
return true;
|
||||
// leap second
|
||||
const utcMin = min - tzM * tzSign;
|
||||
const utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0);
|
||||
return (utcHr === 23 || utcHr === -1) && (utcMin === 59 || utcMin === -1) && sec < 61;
|
||||
};
|
||||
}
|
||||
function compareTime(t1, t2) {
|
||||
function compareTime(s1, s2) {
|
||||
if (!(s1 && s2))
|
||||
return undefined;
|
||||
const t1 = new Date("2020-01-01T" + s1).valueOf();
|
||||
const t2 = new Date("2020-01-01T" + s2).valueOf();
|
||||
if (!(t1 && t2))
|
||||
return undefined;
|
||||
return t1 - t2;
|
||||
}
|
||||
function compareIsoTime(t1, t2) {
|
||||
if (!(t1 && t2))
|
||||
return undefined;
|
||||
const a1 = TIME.exec(t1);
|
||||
const a2 = TIME.exec(t2);
|
||||
if (!(a1 && a2))
|
||||
return undefined;
|
||||
t1 = a1[1] + a1[2] + a1[3] + (a1[4] || "");
|
||||
t2 = a2[1] + a2[2] + a2[3] + (a2[4] || "");
|
||||
t1 = a1[1] + a1[2] + a1[3];
|
||||
t2 = a2[1] + a2[2] + a2[3];
|
||||
if (t1 > t2)
|
||||
return 1;
|
||||
if (t1 < t2)
|
||||
@@ -120,12 +143,24 @@ function compareTime(t1, t2) {
|
||||
return 0;
|
||||
}
|
||||
const DATE_TIME_SEPARATOR = /t|\s/i;
|
||||
function date_time(str) {
|
||||
// http://tools.ietf.org/html/rfc3339#section-5.6
|
||||
const dateTime = str.split(DATE_TIME_SEPARATOR);
|
||||
return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1], true);
|
||||
function getDateTime(strictTimeZone) {
|
||||
const time = getTime(strictTimeZone);
|
||||
return function date_time(str) {
|
||||
// http://tools.ietf.org/html/rfc3339#section-5.6
|
||||
const dateTime = str.split(DATE_TIME_SEPARATOR);
|
||||
return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1]);
|
||||
};
|
||||
}
|
||||
function compareDateTime(dt1, dt2) {
|
||||
if (!(dt1 && dt2))
|
||||
return undefined;
|
||||
const d1 = new Date(dt1).valueOf();
|
||||
const d2 = new Date(dt2).valueOf();
|
||||
if (!(d1 && d2))
|
||||
return undefined;
|
||||
return d1 - d2;
|
||||
}
|
||||
function compareIsoDateTime(dt1, dt2) {
|
||||
if (!(dt1 && dt2))
|
||||
return undefined;
|
||||
const [d1, t1] = dt1.split(DATE_TIME_SEPARATOR);
|
||||
|
||||
Reference in New Issue
Block a user