valgen 4.2.3 → 4.2.4
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/cjs/rules/is-object.js +2 -0
- package/esm/rules/is-object.js +2 -0
- package/package.json +1 -1
- package/typings/rules/is-object.d.ts +1 -1
package/CHANGELOG.md
CHANGED
package/cjs/rules/is-object.js
CHANGED
|
@@ -32,6 +32,8 @@ function isObject(schema, options) {
|
|
|
32
32
|
throw new TypeError(`Invalid definition in validation schema (${k})`);
|
|
33
33
|
});
|
|
34
34
|
const _rule = (0, index_js_1.validator)('isObject', function (input, context, _this) {
|
|
35
|
+
if (typeof input === 'string' && context.coerce)
|
|
36
|
+
input = JSON.parse(input);
|
|
35
37
|
if (!(input && typeof input === 'object')) {
|
|
36
38
|
context.fail(_this, `{{label}} must be an object`, input);
|
|
37
39
|
return;
|
package/esm/rules/is-object.js
CHANGED
|
@@ -29,6 +29,8 @@ export function isObject(schema, options) {
|
|
|
29
29
|
throw new TypeError(`Invalid definition in validation schema (${k})`);
|
|
30
30
|
});
|
|
31
31
|
const _rule = validator('isObject', function (input, context, _this) {
|
|
32
|
+
if (typeof input === 'string' && context.coerce)
|
|
33
|
+
input = JSON.parse(input);
|
|
32
34
|
if (!(input && typeof input === 'object')) {
|
|
33
35
|
context.fail(_this, `{{label}} must be an object`, input);
|
|
34
36
|
return;
|
package/package.json
CHANGED
|
@@ -19,4 +19,4 @@ export interface ObjectValidator<T extends object = object, I = object> extends
|
|
|
19
19
|
* Converts properties according to schema rules if coerce option is set to 'true'.
|
|
20
20
|
* @validator isObject
|
|
21
21
|
*/
|
|
22
|
-
export declare function isObject<T extends object = object, I = object>(schema: ObjectSchema, options?: IsObjectOptions<T>): ObjectValidator<T, I>;
|
|
22
|
+
export declare function isObject<T extends object = object, I = object | string>(schema: ObjectSchema, options?: IsObjectOptions<T>): ObjectValidator<T, I>;
|