Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

ToInt keeps empty string instead of changing to NaN #13

Closed
lazarljubenovic opened this issue Nov 13, 2018 · 2 comments
Closed

ToInt keeps empty string instead of changing to NaN #13

lazarljubenovic opened this issue Nov 13, 2018 · 2 comments

Comments

@lazarljubenovic
Copy link

The ToInt sanitizer doesn't take into account empty string. Looks like a validator.js upstream issue, but since it's currently locked on version 5, which is five major versions behind, it's worth testing if a simple bump will work first. Otherwise this issue should be taken there.

class Query {
  @ToInt()
  readonly page: number
}

const q = new Query() as any
q.page = ''
sanitize(q)

console.log(q) // { page: '' }

Reproduction: https://stackblitz.com/edit/class-sanitizer-to-int-issue?file=index.ts

This happens with query parameters sent as &page=.

@YouriT
Copy link
Contributor

YouriT commented Jan 30, 2019

addressed in swanest@a31bdb9

@NoNameProvided
Copy link
Member

Fixed in v1.0.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants