@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.
19 lines (18 loc) • 560 B
JavaScript
import { isGuid } from './validators/isGuid';
import { recognizedGuid } from './validators/recognizedGuid';
/**
* Parses the {@link ODataSavedQuery.savedQuery savedQuery} or
* {@link ODataUserQuery.userQuery userQuery} query
* @returns Returns `false` when the parse has an error
*/
export const getXQueryFromParser = (X, parser, result) => {
const value = parser.getAll(X);
if (value.length === 0) {
return true;
}
if (!recognizedGuid(value, result) || !isGuid(value, result)) {
return false;
}
result[X] = value[0];
return true;
};