@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.
20 lines (19 loc) • 511 B
JavaScript
import { atMostOnce } from './validators/atMostOnce';
const option = '$select';
/**
* Parses the {@link ODataSelect.$select $select} query
* @returns {boolean} Returns `false` when the parse has an error
*/
export const getSelectFromParser = (parser, result) => {
const value = parser.getAll(option);
if (value.length === 0) {
return true;
}
if (!atMostOnce(option, value, result)) {
return false;
}
if (value.length > 0) {
result.$select = value[0].split(',');
}
return true;
};