UNPKG

skema

Version:

Skema provides a handy & composable way to validate / transform / purify the input data.

42 lines (36 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TypeDefinition = void 0; var _util = require("./util"); // Type Definition /////////////////////////////////////////////////////////// class TypeDefinition { constructor(definition) { const { default: _default, set, validate, when, configurable, enumerable, writable, optional, type, key } = definition; this._default = (0, _util.parseFunction)(_default); this._set = (0, _util.parseSetters)(set); this._validate = (0, _util.parseValidators)(validate); this._when = (0, _util.parseWhen)(when); this._key = (0, _util.parseFunction)(key); this._configurable = configurable; this._enumerable = enumerable; this._writable = writable; // If there is a default value, it IS optional. this._optional = (0, _util.isDefined)(this._default) ? true // By default, optional is false : optional; this._type = type; } } exports.TypeDefinition = TypeDefinition;