@shko.online/dataverse-odata
Version:
This package will help parse OData strings (only the Microsoft Dataverse subset). It can be used as a validator, or you can build some javascript library which consumes the output of this library.
24 lines (23 loc) • 735 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.atMostOnce = void 0;
/**
* Options of this type must be specified at most once.
* @param option The option being validated (ex. $top)
* @param value The result of {@link URLSearchParams.getAll getAll}
* @param result The {@link ODataQuery} to append the error to
* @returns {boolean} Returns `false` when the parse has an error
*/
const atMostOnce = (option, value, result) => {
if (value.length > 1) {
result.error = {
code: '0x0',
message: `Query option '${option}' was specified more than once, but it must be specified at most once.`
};
return false;
}
return true;
};
exports.atMostOnce = atMostOnce;