question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

6.0.1 problem when use optional

See original GitHub issue

Hi. I’m not sure but I think it doesn’t work correct when use optional and then use method like toInt always convert undefined to NaN. I’ve tried this with checkSchema too. query('page').optional().isInt().toInt()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
gustavohenkecommented, Jul 1, 2019

You guys should take a look at v6.1.1. It should fix the problem!

3reactions
blargismcommented, Jul 1, 2019

The following two tests do not pass. They were run in src/matched-data.spec.ts.

describe('when option includeOptionals is false', () => {
  it('returns object without optional data', done => {
    const req = {
      headers: { foo: 'bla', bar: '123' },
    };

    const middleware = check(['foo', 'bar', 'baz'])
      .optional()
      .trim()
      .isString();

    middleware(req, {}, () => {
      const data = matchedData(req, { includeOptionals: false });
      expect(data).toHaveProperty('bar', '123');
      expect(data.baz).toBeUndefined();

      done();
    });
  });
});

describe('when option includeOptionals is not set', () => {
  it('returns object without optional data', done => {
    const req = {
      headers: { foo: 'bla', bar: '123' },
    };

    const middleware = check(['foo', 'bar', 'baz'])
      .optional()
      .trim()
      .isString();

    middleware(req, {}, () => {
      const data = matchedData(req);
      expect(data).toHaveProperty('bar', '123');
      expect(data.baz).toBeUndefined();

      done();
    });
  });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

JRS 6.0.1 is not working right with optional traceability for ...
I am looking for a JRS report with all project work Items ( parent work item) ---> Epics---> stories with Optional traceabiility.
Read more >
UserSecrets should be optional by default #61418 - GitHub
The problem is that the code before .NET 6, didn't really checked if user secrets were being added as optional or not. AddUserSecrets<T>() ......
Read more >
Opinions on using Optional<> as parameter : r/java - Reddit
The use of Optionals as method parameters has been discussed enough here it'd say. As to using it for return values, that's a...
Read more >
Uses for Optional - java - Stack Overflow
The main design goal of Optional is to provide a means for a function returning a value to indicate the absence of a...
Read more >
Breaking changes in EF Core 6.0 - Microsoft Learn
The problems with optional dependents and examples of these mitigations are included in the documentation for What's new in EF Core 6.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found