UNPKG

@martinmilo/verve

Version:

TypeScript domain modeling library with field-level authorization, business rule validation, and context-aware access control

31 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BoundField = void 0; const constants_1 = require("../../constants"); class BoundField { constructor(metadata, options = {}) { this.metadata = metadata; this.options = options; } static toBoundField(model, fieldName, field) { const boundField = Object.create(field); boundField.get = () => field.get(model, fieldName); boundField.unsafeGet = () => field.unsafeGet(model, fieldName); boundField.set = (value) => field.set(model, fieldName, value); boundField.unset = () => field.unset(model, fieldName); boundField.is = (value) => field.is(model, fieldName, value); boundField.isEmpty = () => field.isEmpty(model, fieldName); boundField.isPresent = () => field.isPresent(model, fieldName); boundField.isValid = () => field.isValid(model, fieldName); boundField.validate = () => field.validate(model, fieldName); boundField.generate = () => field.generate(model, fieldName); boundField.compute = () => field.compute(model, fieldName); boundField.isReadable = () => field.isReadable(model, fieldName); boundField.isWritable = () => field.isWritable(model, fieldName); boundField[constants_1.BOUND_FIELD_METADATA] = field.metadata; boundField[constants_1.BOUND_FIELD_OPTIONS] = field.options; return boundField; } } exports.BoundField = BoundField; //# sourceMappingURL=BoundField.js.map