quantique-field-validator 1.0.3-beta → 1.0.3
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.
- package/Validators/validateGST.js +19 -0
- package/index.js +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// GSTIN validation
|
|
2
|
+
const validateGST = (value, rules, defaultErrorMessages, type) => {
|
|
3
|
+
const defaultRegex = /^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}Z{1}[A-Z\d]{1}$/;
|
|
4
|
+
const regexToUse = rules?.regex ? new RegExp(rules.regex) : defaultRegex;
|
|
5
|
+
|
|
6
|
+
if (!regexToUse.test(value)) {
|
|
7
|
+
return {
|
|
8
|
+
isValid: false,
|
|
9
|
+
error:
|
|
10
|
+
rules?.errorMessages?.regex ||
|
|
11
|
+
"Please enterer a valid GSTIN number" ||
|
|
12
|
+
defaultErrorMessages(rules, type).invalid,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return { isValid: true, error: "" };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = validateGST;
|
package/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const validatePassword = require("./Validators/validatePassword");
|
|
|
21
21
|
const validateCustom = require("./Validators/validateCustom");
|
|
22
22
|
const validateAadhaar = require("./Validators/validateAadhaar");
|
|
23
23
|
const validatePanCard = require("./Validators/validatePanCard");
|
|
24
|
+
const validateGST = require("./Validators/validateGST");
|
|
24
25
|
const validateChassisNumber = require("./Validators/ValidateChassisNumber");
|
|
25
26
|
const validateEngineNumber = require("./Validators/validateEngineNumber");
|
|
26
27
|
|
|
@@ -136,6 +137,12 @@ const dynamicValidator = (value, type, rules = {}, customValidator = null) => {
|
|
|
136
137
|
defaultErrorMessages,
|
|
137
138
|
type
|
|
138
139
|
);
|
|
140
|
+
case "aadhaar":
|
|
141
|
+
return validateAadhaar(selectedValue, rules, defaultErrorMessages, type);
|
|
142
|
+
case "pan":
|
|
143
|
+
return validatePanCard(selectedValue, rules, defaultErrorMessages, type);
|
|
144
|
+
case "gst":
|
|
145
|
+
return validateGST(selectedValue, rules, defaultErrorMessages, type);
|
|
139
146
|
case "custom":
|
|
140
147
|
return validateCustom(selectedValue, rules, defaultErrorMessages, type);
|
|
141
148
|
default:
|