@clickup/ent-framework
Version:
A PostgreSQL graph-database-alike library with microsharding and row-level security
32 lines • 1.12 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.RowIs = void 0;
const maybeThrowEntValidationError_1 = require("./internal/maybeThrowEntValidationError");
/**
* Checks that the validator function returns true for the entire row.
*/
class RowIs {
constructor(validator, message) {
this.field = null;
this.name = this.constructor.name;
this.message = message ?? null;
this.validator = validator;
}
/**
* Returns true if validation succeeds. Returns false if it wants the client
* to use this.message as a validation failure response. Throws an instance of
* EntValidationError when it needs to deliver the detailed error messages
* about multiple fields.
*/
async check(vc, row) {
const res = await this.validator(row, vc);
return (0, maybeThrowEntValidationError_1.maybeThrowEntValidationError)({
name: this.name,
field: null,
res,
allowRichResult: this.message === null,
});
}
}
exports.RowIs = RowIs;
//# sourceMappingURL=RowIs.js.map
;