handsontable
Version:
Handsontable is a JavaScript Data Grid available for React, Angular and Vue.
39 lines (36 loc) • 1.36 kB
JavaScript
;
exports.__esModule = true;
exports.intlTimeValidator = intlTimeValidator;
exports.sourceDataValidator = sourceDataValidator;
var _dateTime = require("../../helpers/dateTime");
var _mixed = require("../../helpers/mixed");
const VALIDATOR_TYPE = exports.VALIDATOR_TYPE = 'intl-time';
const SOURCE_DATA_WARNING_MESSAGE = exports.SOURCE_DATA_WARNING_MESSAGE = 'Source data warning ([itemsCount]). ' + 'Invalid value for "intl-time" cell type.\n\n' + '[affectedCells]\n\n' + 'Expected a value compatible with the 24-hour time format ("HH:mm", "HH:mm:ss" or "HH:mm:ss.SSS").';
/**
* 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.isValidTime)(value);
}
/**
* The IntlTime cell validator.
*
* @private
* @param {*} value Value of edited cell.
* @param {Function} callback Callback called with validation result.
*/
function intlTimeValidator(value, callback) {
if (this.allowEmpty && (0, _mixed.isEmpty)(value)) {
callback(true);
return;
}
callback((0, _dateTime.isValidTime)(value));
}
intlTimeValidator.VALIDATOR_TYPE = VALIDATOR_TYPE;