Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add booleanMapper into mappers #53

Closed
4 tasks
Siemienik opened this issue Oct 18, 2020 · 3 comments
Closed
4 tasks

Add booleanMapper into mappers #53

Siemienik opened this issue Oct 18, 2020 · 3 comments
Labels
good first issue Good for newcomers

Comments

@Siemienik
Copy link
Owner

Part of #21

TODO:

  1. Create file src/mappers/booleanMapper.ts with function matches to type ValueMapper<boolean>. Which parse value string into boolean.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test
  4. Describe it in Readme.md

proposed test data provider:

const dataProvider = [
  { inValue: null, expectedResult: false },
  { inValue: '', expectedResult: false },
  { inValue: '  ', expectedResult: false },
  { inValue: '0', expectedResult: false },
  { inValue: '000', expectedResult: false },
  { inValue: 'true', expectedResult: false },
  { inValue: 'false', expectedResult: false },
  { inValue: 'a0.1', expectedResult: false},

  { inValue: '001', expectedResult: true },
  { inValue: '123', expectedResult: true },
  { inValue: '0.1', expectedResult: true},
  { inValue: '-1', expectedResult: true},
  { inValue: '   -1.2123asd', expectedResult: true}
];

tips:

  • I propose to use Boolean(Number())

For making a reservation please open draft PR with this issue linked

@machadolucasvp
Copy link
Contributor

Hello @Siemienik, are you sure we should expect inValue: ' -1.2123asd' be mapped to true ?

@Siemienik
Copy link
Owner Author

Siemienik commented Oct 19, 2020

Hello @Siemienik, are you sure we should expect inValue: ' -1.2123asd' be mapped to true ?

It's quite problematic question, but when I wrote this issue I've followed the result of Boolean(Number.parseFloat()). That result true for this input.

@Siemienik
Copy link
Owner Author

done in #54

Repository owner locked as resolved and limited conversation to collaborators Oct 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants