UNPKG

@truepic/queryql

Version:

Easily add filtering, sorting, and pagination to your REST API through your old friend: the query string!

31 lines (23 loc) 608 B
const NotImplementedError = require('../../errors/not_implemented') const ValidationError = require('../../errors/validation') class BaseValidator { constructor(defineSchema) { this.schema = defineSchema(...this.defineSchemaArgs) } validateFilters(/* filters */) { throw new NotImplementedError() } validateSorts(/* sorts */) { throw new NotImplementedError() } validatePage(/* page */) { throw new NotImplementedError() } get defineSchemaArgs() { return [] } buildError(message) { return new ValidationError(message) } } module.exports = BaseValidator