@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) • 553 B
JavaScript
import { atMostOnce } from './validators/atMostOnce';
const option = '$filter';
/**
* Parses the {@link ODataFilter.$filter $filter} query
* @returns {boolean} Returns `false` when the parse has an error
*/
export const getFilterFromParser = (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.$filter = {
operator: 'eq',
left: '',
right: ''
};
}
return true;
};