UNPKG

handsontable

Version:

Handsontable is a JavaScript Data Grid available for React, Angular and Vue.

39 lines (36 loc) 1.34 kB
"use strict"; exports.__esModule = true; exports.intlDateValidator = intlDateValidator; exports.sourceDataValidator = sourceDataValidator; var _dateTime = require("../../helpers/dateTime"); var _mixed = require("../../helpers/mixed"); const VALIDATOR_TYPE = exports.VALIDATOR_TYPE = 'intl-date'; const SOURCE_DATA_WARNING_MESSAGE = exports.SOURCE_DATA_WARNING_MESSAGE = 'Source data warning ([itemsCount]). ' + 'Invalid value for "intl-date" cell type.\n\n' + '[affectedCells]\n\n' + 'Expected a value compatible with the ISO 8601 date format ("YYYY-MM-DD").'; /** * Source data validator. * * @param {*} value Value of the source data of the cell. * @param {CellMeta} cellMeta Cell meta object. * @returns {boolean} True if valid, false otherwise. */ function sourceDataValidator(value, cellMeta) { if (cellMeta.allowEmpty && (0, _mixed.isEmpty)(value)) { return true; } return (0, _dateTime.isValidISODate)(value); } /** * The Date cell validator. * * @private * @param {*} value Value of edited cell. * @param {Function} callback Callback called with validation result. */ function intlDateValidator(value, callback) { if (this.allowEmpty && (0, _mixed.isEmpty)(value)) { callback(true); return; } callback((0, _dateTime.isValidISODate)(value)); } intlDateValidator.VALIDATOR_TYPE = VALIDATOR_TYPE;