equipped 5.0.0-beta-2 → 5.0.0-beta-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/CHANGELOG.md +7 -0
- package/lib/validations/index.d.ts +1 -1
- package/lib/validations/index.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [5.0.0-beta-3](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-2...v5.0.0-beta-3) (2024-05-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* allow custom validator in validate ([24a1d7a](https://github.com/kevinand11/equipped/commit/24a1d7a7cf69eabc73148dd9d36324d32ba95fc3))
|
|
11
|
+
|
|
5
12
|
## [5.0.0-beta-2](https://github.com/kevinand11/equipped/compare/v5.0.0-beta-1...v5.0.0-beta-2) (2024-05-30)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -154,7 +154,7 @@ export declare const Validation: {
|
|
|
154
154
|
ignored: boolean;
|
|
155
155
|
};
|
|
156
156
|
};
|
|
157
|
-
export declare const validate: <T extends Record<string, Validate.VCore<any
|
|
157
|
+
export declare const validate: <T extends Record<string, Validate.VCore<any>>, S extends Validate.VCore<any> = Validate.VCore<any>>(schema: T | S, value: unknown) => any;
|
|
158
158
|
export declare const Hash: {
|
|
159
159
|
hash: (password: string) => Promise<string>;
|
|
160
160
|
compare: (plainPassword: string, hashed: string) => Promise<boolean>;
|
package/lib/validations/index.js
CHANGED
|
@@ -48,7 +48,8 @@ Validate.v.file = (...args) => file(...args).addRule(isNotTruncated());
|
|
|
48
48
|
exports.Schema = Validate.v;
|
|
49
49
|
exports.Validation = { ...Validate, isNotTruncated, isValidPhone };
|
|
50
50
|
const validate = (schema, value) => {
|
|
51
|
-
const
|
|
51
|
+
const validator = schema instanceof Validate.VCore ? schema : Validate.v.object(schema);
|
|
52
|
+
const validity = validator.parse(value);
|
|
52
53
|
if (validity.valid)
|
|
53
54
|
return validity.value;
|
|
54
55
|
const errorsObject = validity.errors
|