ts-db-helper
Version:
Simple ORM based on TypeScript
23 lines • 968 B
JavaScript
import * as tslib_1 from "tslib";
import { FieldSerializerError } from './field-serializer.error';
import { FieldSerializer } from './field-serializer';
var BooleanFieldSerializer = /** @class */ (function (_super) {
tslib_1.__extends(BooleanFieldSerializer, _super);
function BooleanFieldSerializer(fieldName, jsonKey, config) {
var _this = _super.call(this, fieldName, jsonKey, config) || this;
_this.rules.type = 'Boolean';
return _this;
}
BooleanFieldSerializer.prototype.checkFieldRules = function (data) {
var value = data[this.jsonKey];
if (value !== true && value !== false) {
return new FieldSerializerError(this.jsonKey, 'Field is not boolean', this.rules);
}
else {
return null;
}
};
return BooleanFieldSerializer;
}(FieldSerializer));
export { BooleanFieldSerializer };
//# sourceMappingURL=boolean.field-serializer.js.map