From a6644cba9f1c91b328446b57aa5b1c13e1815d5f Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Sat, 15 Jun 2024 01:42:29 +0545 Subject: [PATCH 1/2] fix: spell issues --- README.md | 2 +- src/lib/contains.js | 4 ++-- src/lib/isEAN.js | 4 ++-- src/lib/isIMEI.js | 8 ++++---- src/lib/isMimeType.js | 8 ++++---- src/lib/isTaxID.js | 24 ++++++++++++------------ test/validators.test.js | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 79b6426b4..4a84f97cb 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Here is a list of the validators currently available. Validator | Description --------------------------------------- | -------------------------------------- -**contains(str, seed [, options])** | check if the string contains the seed.

`options` is an object that defaults to `{ ignoreCase: false, minOccurrences: 1 }`.
Options:
`ignoreCase`: Ignore case when doing comparison, default false.
`minOccurences`: Minimum number of occurrences for the seed in the string. Defaults to 1. +**contains(str, seed [, options])** | check if the string contains the seed.

`options` is an object that defaults to `{ ignoreCase: false, minOccurrences: 1 }`.
Options:
`ignoreCase`: Ignore case when doing comparison, default false.
`minOccurrences`: Minimum number of occurrences for the seed in the string. Defaults to 1. **equals(str, comparison)** | check if the string matches the comparison. **isAbaRouting(str)** | check if the string is an ABA routing number for US bank account / cheque. **isAfter(str [, options])** | check if the string is a date that is after the specified date.

`options` is an object that defaults to `{ comparisonDate: Date().toString() }`.
**Options:**
`comparisonDate`: Date to compare to. Defaults to `Date().toString()` (now). diff --git a/src/lib/contains.js b/src/lib/contains.js index 7be314b04..8e716c4be 100644 --- a/src/lib/contains.js +++ b/src/lib/contains.js @@ -2,14 +2,14 @@ import assertString from './util/assertString'; import toString from './util/toString'; import merge from './util/merge'; -const defaulContainsOptions = { +const defaultContainsOptions = { ignoreCase: false, minOccurrences: 1, }; export default function contains(str, elem, options) { assertString(str); - options = merge(options, defaulContainsOptions); + options = merge(options, defaultContainsOptions); if (options.ignoreCase) { return str.toLowerCase().split(toString(elem).toLowerCase()).length > options.minOccurrences; diff --git a/src/lib/isEAN.js b/src/lib/isEAN.js index 968c385dd..731932ad3 100644 --- a/src/lib/isEAN.js +++ b/src/lib/isEAN.js @@ -15,9 +15,9 @@ import assertString from './util/assertString'; /** - * Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13; 14 for EAN-14 + * Define EAN Lengths; 8 for EAN-8; 13 for EAN-13; 14 for EAN-14 * and Regular Expression for valid EANs (EAN-8, EAN-13, EAN-14), - * with exact numberic matching of 8 or 13 or 14 digits [0-9] + * with exact numeric matching of 8 or 13 or 14 digits [0-9] */ const LENGTH_EAN_8 = 8; const LENGTH_EAN_14 = 14; diff --git a/src/lib/isIMEI.js b/src/lib/isIMEI.js index fb97d4924..984b4fb88 100644 --- a/src/lib/isIMEI.js +++ b/src/lib/isIMEI.js @@ -1,8 +1,8 @@ import assertString from './util/assertString'; -let imeiRegexWithoutHypens = /^[0-9]{15}$/; -let imeiRegexWithHypens = /^\d{2}-\d{6}-\d{6}-\d{1}$/; +let imeiRegexWithoutHyphens = /^[0-9]{15}$/; +let imeiRegexWithHyphens = /^\d{2}-\d{6}-\d{6}-\d{1}$/; export default function isIMEI(str, options) { @@ -11,10 +11,10 @@ export default function isIMEI(str, options) { // default regex for checking imei is the one without hyphens - let imeiRegex = imeiRegexWithoutHypens; + let imeiRegex = imeiRegexWithoutHyphens; if (options.allow_hyphens) { - imeiRegex = imeiRegexWithHypens; + imeiRegex = imeiRegexWithHyphens; } diff --git a/src/lib/isMimeType.js b/src/lib/isMimeType.js index 4081117af..820fa4dc2 100644 --- a/src/lib/isMimeType.js +++ b/src/lib/isMimeType.js @@ -4,18 +4,18 @@ import assertString from './util/assertString'; Checks if the provided string matches to a correct Media type format (MIME type) This function only checks is the string format follows the - etablished rules by the according RFC specifications. + established rules by the according RFC specifications. This function supports 'charset' in textual media types (https://tools.ietf.org/html/rfc6657). This function does not check against all the media types listed by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml) because of lightness purposes : it would require to include - all these MIME types in this librairy, which would weigh it + all these MIME types in this library, which would weigh it significantly. This kind of effort maybe is not worth for the use that - this function has in this entire librairy. + this function has in this entire library. - More informations in the RFC specifications : + More information in the RFC specifications : - https://tools.ietf.org/html/rfc2045 - https://tools.ietf.org/html/rfc2046 - https://tools.ietf.org/html/rfc7231#section-3.1.1.1 diff --git a/src/lib/isTaxID.js b/src/lib/isTaxID.js index d13229f69..14d27158b 100644 --- a/src/lib/isTaxID.js +++ b/src/lib/isTaxID.js @@ -174,24 +174,24 @@ function deDeCheck(tin) { const digits = tin.split('').map(a => parseInt(a, 10)); // Fill array with strings of number positions - let occurences = []; + let occurrences = []; for (let i = 0; i < digits.length - 1; i++) { - occurences.push(''); + occurrences.push(''); for (let j = 0; j < digits.length - 1; j++) { if (digits[i] === digits[j]) { - occurences[i] += j; + occurrences[i] += j; } } } - // Remove digits with one occurence and test for only one duplicate/triplicate - occurences = occurences.filter(a => a.length > 1); - if (occurences.length !== 2 && occurences.length !== 3) { return false; } + // Remove digits with one occurrence and test for only one duplicate/triplicate + occurrences = occurrences.filter(a => a.length > 1); + if (occurrences.length !== 2 && occurrences.length !== 3) { return false; } // In case of triplicate value only two digits are allowed next to each other - if (occurences[0].length === 3) { - const trip_locations = occurences[0].split('').map(a => parseInt(a, 10)); - let recurrent = 0; // Amount of neighbour occurences + if (occurrences[0].length === 3) { + const trip_locations = occurrences[0].split('').map(a => parseInt(a, 10)); + let recurrent = 0; // Amount of neighbor occurrences for (let i = 0; i < trip_locations.length - 1; i++) { if (trip_locations[i] + 1 === trip_locations[i + 1]) { recurrent += 1; @@ -621,10 +621,10 @@ function huHuCheck(tin) { * and X characters after vowels may only be followed by other X characters. */ function itItNameCheck(name) { - // true at the first occurence of a vowel + // true at the first occurrence of a vowel let vowelflag = false; - // true at the first occurence of an X AFTER vowel + // true at the first occurrence of an X AFTER vowel // (to properly handle last names with X as consonant) let xflag = false; @@ -890,7 +890,7 @@ function plPlCheck(tin) { const date = `${full_year}/${month}/${tin.slice(4, 6)}`; if (!isDate(date, 'YYYY/MM/DD')) { return false; } - // Calculate last digit by mulitplying with odd one-digit numbers except 5 + // Calculate last digit by multitplying with odd one-digit numbers except 5 let checksum = 0; let multiplier = 1; for (let i = 0; i < tin.length - 1; i++) { diff --git a/test/validators.test.js b/test/validators.test.js index 8037acf37..48379eb8b 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -14835,7 +14835,7 @@ describe('Validators', () => { ], invalid: [ '', - 'somthing', + 'something', 'valid@gmail.com', 'mailto:?subject=okay&subject=444', 'mailto:?subject=something&wrong=888', From 2d5d2cec044ca8ac7817b3f2ad9d225145d77950 Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Sat, 15 Jun 2024 01:59:59 +0545 Subject: [PATCH 2/2] Update src/lib/isTaxID.js Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com> --- src/lib/isTaxID.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/isTaxID.js b/src/lib/isTaxID.js index 14d27158b..5e5f8cb5b 100644 --- a/src/lib/isTaxID.js +++ b/src/lib/isTaxID.js @@ -890,7 +890,7 @@ function plPlCheck(tin) { const date = `${full_year}/${month}/${tin.slice(4, 6)}`; if (!isDate(date, 'YYYY/MM/DD')) { return false; } - // Calculate last digit by multitplying with odd one-digit numbers except 5 + // Calculate last digit by multiplying with odd one-digit numbers except 5 let checksum = 0; let multiplier = 1; for (let i = 0; i < tin.length - 1; i++) {