quantique-field-validator 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ const defaultErrorMessages = (rules, type) => {
8
8
  required: "This field is required",
9
9
  minLength: `Minimum length should be ${rules.minLength}`,
10
10
  maxLength: `Maximum length should be ${rules.maxLength}`,
11
- invalid: `Invalid ${type}`,
11
+ invalid: `Please entere a valid ${type}`,
12
12
  noValidation: `No validation exist for ${type}`,
13
13
  custom: "Validation failed",
14
14
  Alphanumeric: "value must be alphanumeric",
@@ -1,18 +1,14 @@
1
1
  const validateAadhaar = (value, rules, defaultErrorMessages, type) => {
2
- const defaultRules = {
3
- regex: /^[2-9]{1}[0-9]{11}$/,
4
- };
5
- const effectiveRules = {
6
- ...defaultRules,
7
- ...rules,
8
- };
2
+ const defaultRegex = /^[2-9]{1}[0-9]{11}$/;
3
+ const regexToUse = rules?.regex ? new RegExp(rules.regex) : defaultRegex;
9
4
 
10
- if (effectiveRules?.regex && !new RegExp(effectiveRules?.regex).test(value)) {
5
+ if (!regexToUse.test(value)) {
11
6
  return {
12
7
  isValid: false,
13
8
  error:
14
- effectiveRules?.errorMessages?.invalid ||
15
- defaultErrorMessages(effectiveRules, type).invalid,
9
+ rules?.errorMessages?.regex ||
10
+ rules?.errorMessages?.invalid ||
11
+ defaultErrorMessages(rules, type).invalid,
16
12
  };
17
13
  }
18
14
 
@@ -8,12 +8,12 @@ const validateGST = (value, rules, defaultErrorMessages, type) => {
8
8
  isValid: false,
9
9
  error:
10
10
  rules?.errorMessages?.regex ||
11
- "Please entere a valid GSTIN number" ||
11
+ rules?.errorMessages?.invalid ||
12
12
  defaultErrorMessages(rules, type).invalid,
13
13
  };
14
14
  }
15
15
 
16
- return { isValid: true, error: "" };
16
+ return { isValid: true, error: '' };
17
17
  };
18
18
 
19
19
  module.exports = validateGST;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quantique-field-validator",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Validator to verify all form fields.",
5
5
  "main": "index.js",
6
6
  "scripts": {