No need for double negation

This commit is contained in:
Gert Hengeveld 2021-02-26 09:53:08 +01:00
parent ea0bda5646
commit a4f6dd4e8e
2 changed files with 4 additions and 4 deletions

View File

@ -11,8 +11,8 @@ const validateArgs = (key = '', value: unknown): boolean => {
if (key === '' || !VALIDATION_REGEXP.test(key)) return false;
if (typeof value === 'number' || typeof value === 'boolean') return true;
if (typeof value === 'string') return VALIDATION_REGEXP.test(value);
if (Array.isArray(value)) return !value.some((v) => !validateArgs(key, v));
if (isPlainObject(value)) return !Object.entries(value).some(([k, v]) => !validateArgs(k, v));
if (Array.isArray(value)) return value.every((v) => validateArgs(key, v));
if (isPlainObject(value)) return Object.entries(value).every(([k, v]) => validateArgs(k, v));
return false;
};

View File

@ -76,8 +76,8 @@ const validateArgs = (key = '', value: unknown): boolean => {
if (key === '' || !VALIDATION_REGEXP.test(key)) return false;
if (typeof value === 'number' || typeof value === 'boolean') return true;
if (typeof value === 'string') return VALIDATION_REGEXP.test(value);
if (Array.isArray(value)) return !value.some((v) => !validateArgs(key, v));
if (isPlainObject(value)) return !Object.entries(value).some(([k, v]) => !validateArgs(k, v));
if (Array.isArray(value)) return value.every((v) => validateArgs(key, v));
if (isPlainObject(value)) return Object.entries(value).every(([k, v]) => validateArgs(k, v));
return false;
};