UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

32 lines (31 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NumberSchema = void 0; const index_js_1 = require("../../errors/index.js"); const isBoolean_js_1 = require("../../utils/validation/isBoolean.js"); const check_js_1 = require("../primitive/check.js"); class NumberSchema { constructor(props) { this.type = 'number'; this.props = props; } get checked() { return Object.isFrozen(this.props); } check(path) { if (this.checked) { return; } (0, check_js_1.checkPrimitiveSchema)(this, path); const { big } = this.props; if (big !== undefined && !(0, isBoolean_js_1.isBoolean)(big)) { throw new index_js_1.DynamoDBToolboxError('schema.invalidProp', { message: `Invalid property type${path !== undefined ? ` at path '${path}'` : ''}. Property: 'big'. Expected: boolean. Received: ${String(big)}.`, path, payload: { propName: 'big', received: big } }); } Object.freeze(this.props); } } exports.NumberSchema = NumberSchema;