MCPcopy
hub / github.com/sequelize/sequelize / DECIMAL

Class DECIMAL

lib/data-types.js:328–348  ·  view source on GitHub ↗

* Decimal type, variable precision, take length as specified by user

Source from the content-addressed store, hash-verified

326 * Decimal type, variable precision, take length as specified by user
327 */
328class DECIMAL extends NUMBER {
329 /**
330 * @param {string|number} [precision] defines precision
331 * @param {string|number} [scale] defines scale
332 */
333 constructor(precision, scale) {
334 super(typeof precision === 'object' && precision || { precision, scale });
335 }
336 toSql() {
337 if (this._precision || this._scale) {
338 return `DECIMAL(${[this._precision, this._scale].filter(_.identity).join(',')})`;
339 }
340 return 'DECIMAL';
341 }
342 validate(value) {
343 if (!Validator.isDecimal(String(value))) {
344 throw new sequelizeErrors.ValidationError(util.format('%j is not a valid decimal', value));
345 }
346 return true;
347 }
348}
349
350// TODO: Create intermediate class
351const protoExtensions = {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…