Comparing version 1.1.1 to 1.2.0
@@ -8,2 +8,3 @@ export * from './any'; | ||
export * from './object'; | ||
export * from './partial'; | ||
export * from './record'; | ||
@@ -10,0 +11,0 @@ export * from './regex'; |
@@ -24,2 +24,3 @@ "use strict"; | ||
__exportStar(require("./object"), exports); | ||
__exportStar(require("./partial"), exports); | ||
__exportStar(require("./record"), exports); | ||
@@ -26,0 +27,0 @@ __exportStar(require("./regex"), exports); |
@@ -19,12 +19,6 @@ import type { CommonSchemaOptions } from '../../types/common-schema-options'; | ||
map: InferRecordOfSchemasFromRecordOfValues<ObjectT>; | ||
partial: () => Schema<Partial<ObjectT>>; | ||
} | ||
/** Requires an object. Separate schemas a specified per key. */ | ||
export declare const object: <ObjectT extends Record<string, any>>(map: InferRecordOfSchemasFromRecordOfValues<ObjectT>, options?: CommonSchemaOptions) => ObjectSchema<ObjectT>; | ||
export interface PartialSchema<ObjectT extends Record<string, any>> extends Schema<Partial<ObjectT>> { | ||
schemaType: 'partial'; | ||
schema: ObjectSchema<ObjectT>; | ||
} | ||
export declare const partial: <ObjectT extends Record<string, any>>(schema: ObjectSchema<ObjectT>, options?: CommonSchemaOptions) => PartialSchema<ObjectT>; | ||
export {}; | ||
//# sourceMappingURL=object.d.ts.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.partial = exports.object = void 0; | ||
exports.object = void 0; | ||
const async_time_complexity_threshold_1 = require("../../config/async-time-complexity-threshold"); | ||
@@ -19,3 +19,2 @@ const get_meaningful_typeof_1 = require("../../type-utils/get-meaningful-typeof"); | ||
const path_utils_1 = require("../internal/utils/path-utils"); | ||
const optional_1 = require("../marker-types/optional"); | ||
/** Requires an object. Separate schemas a specified per key. */ | ||
@@ -113,19 +112,6 @@ const object = (map, options = {}) => { | ||
}); | ||
const fullObjectSchema = (0, internal_schema_maker_1.makeInternalSchema)(Object.assign(Object.assign({ valueType: undefined, schemaType: 'object' }, options), { estimatedValidationTimeComplexity, usesCustomSerDes: needsDeepSerDes, map, partial: () => (0, exports.partial)(fullObjectSchema) }), { internalValidate, internalValidateAsync }); | ||
const fullObjectSchema = (0, internal_schema_maker_1.makeInternalSchema)(Object.assign(Object.assign({ valueType: undefined, schemaType: 'object' }, options), { estimatedValidationTimeComplexity, usesCustomSerDes: needsDeepSerDes, map }), { internalValidate, internalValidateAsync }); | ||
return fullObjectSchema; | ||
}; | ||
exports.object = object; | ||
const partial = (schema, options = {}) => { | ||
const outputMap = {}; | ||
for (const key of Object.keys(schema.map)) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
outputMap[key] = (0, optional_1.optional)(schema.map[key]); | ||
} | ||
const partialSchema = (0, exports.object)(outputMap); | ||
return (0, internal_schema_maker_1.makeInternalSchema)(Object.assign(Object.assign({ valueType: undefined, schemaType: 'partial', schema }, options), { estimatedValidationTimeComplexity: partialSchema.estimatedValidationTimeComplexity, usesCustomSerDes: partialSchema.usesCustomSerDes }), { | ||
internalValidate: partialSchema.internalValidate, | ||
internalValidateAsync: partialSchema.internalValidateAsync | ||
}); | ||
}; | ||
exports.partial = partial; | ||
//# sourceMappingURL=object.js.map |
{ | ||
"name": "yaschema", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Yet another schema", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
272
3127
285958