RocksonZeta / koa-validate

validate koa request params and format request params
https://github.com/RocksonZeta/koa-validate
MIT License
284 stars 32 forks source link

Can't use optional with sanitizers. #25

Closed pongib closed 7 years ago

pongib commented 7 years ago

This is my code

const getValidation = function* (next) {
  this.checkQuery('limit').optional().len(1, 100).trim().toInt()
  this.checkQuery('offset').optional().len(1, 100).trim().toInt()

  if (this.errors) {
    this.status = 400
    this.body = this.errors
    return
  }
  yield next
}

router.get('/something', getValidation, Ctrl.get)

When I send GET without offset query params, It will populate error with TypeError: This library (validator.js) validates strings only. If I did something wrong just point me to correct please. Thank you.

RocksonZeta commented 7 years ago

thanks, this bug has been fixed at 1.0.7 .