ducktyper
Version:
A tool for validating input based on the fundamental js idea of duck typing. The object of this is to allow for clearer input validation and specification from the perspective of the developer. It will reduce the amount of time it takes to do input valida
28 lines (27 loc) • 997 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.initClassifyDuckOptions = exports.initIsDuckOptions = exports.CLASIFYDUCK_OPTIONS = exports.ISDUCK_OPTIONS = void 0;
exports.ISDUCK_OPTIONS = {
throw: false,
allowUndefined: false,
allowEmpty: true,
allowEmptyString: undefined,
allowEmptyArray: undefined,
childMessage: true,
message: `Not A Duck: Input failed to follow specifications`,
forceDuckDto: false,
};
exports.CLASIFYDUCK_OPTIONS = Object.assign(Object.assign({}, exports.ISDUCK_OPTIONS), { message: undefined });
function afix(objA, objB) {
for (const property in objB) {
objA[property] = objB[property];
}
}
function initIsDuckOptions(obj) {
afix(exports.ISDUCK_OPTIONS, obj);
}
exports.initIsDuckOptions = initIsDuckOptions;
function initClassifyDuckOptions(obj) {
afix(exports.CLASIFYDUCK_OPTIONS, obj);
}
exports.initClassifyDuckOptions = initClassifyDuckOptions;