validno 0.1.5 → 0.1.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.
- package/dist/checkRules.js +1 -1
- package/dist/checkType.js +4 -2
- package/package.json +1 -1
- package/src/checkRules.ts +1 -1
- package/src/checkType.ts +4 -2
package/dist/checkRules.js
CHANGED
|
@@ -67,7 +67,7 @@ const rulesFunctions = {
|
|
|
67
67
|
lengthMinMax: (key, val, minMax) => {
|
|
68
68
|
const [min, max] = minMax;
|
|
69
69
|
return {
|
|
70
|
-
result: _validations.lengthMin(val, min) && _validations.
|
|
70
|
+
result: _validations.lengthMin(val, min) && _validations.lengthMax(val, max),
|
|
71
71
|
details: `Длина должна быть от ${min} до ${max} символов`
|
|
72
72
|
};
|
|
73
73
|
},
|
package/dist/checkType.js
CHANGED
|
@@ -82,10 +82,12 @@ const checkType = (key, value, requirements, keyName = key) => {
|
|
|
82
82
|
break;
|
|
83
83
|
case Date:
|
|
84
84
|
const isDate = isNotNull && value.constructor === Date;
|
|
85
|
+
const isValid = isDate && !isNaN(value.getTime());
|
|
86
|
+
const errorMsg = isValid ? getErrorDetails(keyName, requirements.type, value) : 'Дата невалидна';
|
|
85
87
|
result.push({
|
|
86
88
|
key: keyName,
|
|
87
|
-
passed: isDate,
|
|
88
|
-
details: isDate ? 'Passed' :
|
|
89
|
+
passed: isDate && isValid,
|
|
90
|
+
details: isDate && isValid ? 'Passed' : errorMsg
|
|
89
91
|
});
|
|
90
92
|
break;
|
|
91
93
|
case Boolean:
|
package/package.json
CHANGED
package/src/checkRules.ts
CHANGED
|
@@ -77,7 +77,7 @@ const rulesFunctions: any = {
|
|
|
77
77
|
const [min, max] = minMax
|
|
78
78
|
|
|
79
79
|
return {
|
|
80
|
-
result: _validations.lengthMin(val, min) && _validations.
|
|
80
|
+
result: _validations.lengthMin(val, min) && _validations.lengthMax(val, max),
|
|
81
81
|
details: `Длина должна быть от ${min} до ${max} символов`
|
|
82
82
|
}
|
|
83
83
|
},
|
package/src/checkType.ts
CHANGED
|
@@ -95,11 +95,13 @@ const checkType = (key: string, value: any, requirements: TSchemaItem | TSchemaI
|
|
|
95
95
|
break;
|
|
96
96
|
case Date:
|
|
97
97
|
const isDate = isNotNull && value.constructor === Date
|
|
98
|
+
const isValid = isDate && !isNaN(value.getTime())
|
|
99
|
+
const errorMsg = isValid ? getErrorDetails(keyName, requirements.type, value) : 'Дата невалидна'
|
|
98
100
|
|
|
99
101
|
result.push({
|
|
100
102
|
key: keyName,
|
|
101
|
-
passed: isDate,
|
|
102
|
-
details: isDate ? 'Passed' :
|
|
103
|
+
passed: isDate && isValid,
|
|
104
|
+
details: isDate && isValid ? 'Passed' : errorMsg
|
|
103
105
|
})
|
|
104
106
|
break;
|
|
105
107
|
case Boolean:
|