exports.validate = function (column, value) { if (value === '' || value === 'NULL' || value === null || value === undefined || (value instanceof Array && !value.length)) { // should check for column.defaultValue too if (!column.allowNull) { return new Error('Column '+column.name+' cannot be empty.'); } else { return null; } } if (column.control.date) { if (moment(value).isValid()) { value = moment(value).format('YYYY-MM-DD'); } } if (column.control.datetime) { if (moment(value).isValid()) { value = moment(value).format('YYYY-MM-DD hh:mm:ss'); } } if (column.control.radio) { if (value === true) value = 't'; else if (value === false) value = 'f'; } return validator.check(value, column.type); }
exports.validate = function (column, value) { if (value === '' || value === 'NULL' || value === null || (value instanceof Array && !value.length)) { // should check for column.defaultValue too if (!column.allowNull) { return new Error('Column '+column.name+' cannot be empty.'); } else { return null; } } return validator.check(value, column.type); }
exports.value = function (column, value) { if (value === '' || value === null || value === undefined || (value instanceof Array && !value.length)) { // should check for column.defaultValue when creating a record if (column.allowNull) return null; if (column.control.binary) return null; //temp disabled return new Error('Column '+column.name+' cannot be empty.'); } value = format(column, value); return validator.check(value, column.type); }