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.

Suggestion: parser.failIf(cond, message)

See original GitHub issue

I wish there are kind of this.

parser.failIf(v => someExpression, "error message")

It is a shorthand of this:

parser.chain(v => condition(v) ? P.fail(message) : P.succeed(v))

Isn’t it reasonable?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wavebeemcommented, Jul 18, 2019

How about the opposite, .assert?

const listParser = P.seq(P.index, P.string("- "), P.regex(...))
  .map(([index, _1, value]) => ({index, value}))
  // Markdown list should be started from multiple of 2 spaces
  .assert(v => v.index.column % 2 === 0, "indentation error")
  .map(...);
0reactions
wavebeemcommented, Jul 26, 2019

Version 1.13.0 released!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Error while parsing JSON: 'Unexpected character en...
Http request failed: the content was not a valid JSON. Error while parsing JSON: 'Unexpected character encountered while parsing value: A. Path '',...
Read more >
Auto-completion suggestions from parse error - Stack Overflow
I am writing a parser for a custom jupter kernel using megaparsec. I was able to re-use the parser to provide completions too:...
Read more >
Resolving problems when using messages - IBM
Explanation: The MRM parser has failed to parse the message. Solution: Modify the attribute names so that they are not identical. This problem ......
Read more >
How to detect a parser error based on a Log Decoder error ...
Issue. In the event of a syntax error when a custom change is made to device parser, errors appear in the in /var/log/messages...
Read more >
XSL Transformations (XSLT) Version 3.0 - W3C
XSLT 3.0 is a revised version of the XSLT 2.0 Recommendation [XSLT ... of xsl:message 19.8.4.27 Streamability of xsl:namespace 19.8.4.28 ...
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