What does that actually mean? Actually pointing to the specific range and location of invalid input rather than "there is an error in here somewhere".
-
Show this thread
-
Rome ingests package.json files and performs some normalization and validation. One of the fields is name. When you use a package.json name in npm or yarn that is invalid, it will just yell at you. Rome points to the exact location with some possible hints. Examples:
1 reply 0 retweets 4 likesShow this thread -
2 replies 0 retweets 16 likesShow this thread -
Replying to @sebmck
Curious to see how you keep these organized and maintainable. It feels like a *lot* of highly specific code maybe?
1 reply 0 retweets 0 likes -
Replying to @tmdpw
Not really. You queue up errors, always recovering from them by normalizing input etc. Then you have a boundary where you either dump the errors and stop, or write the normalized values somewhere when there's a --fix flag. Easily abstracted.
1 reply 0 retweets 0 likes -
Replying to @sebmck
No, I get that. My question was more around the multitude of possible errors. I imagine there's a separate module for every single test, so how will maintainers know that the validator they want to add exists already? Documentation discipline? Kinda reminds me of ESLint rules.
1 reply 0 retweets 0 likes -
Replying to @tmdpw
The validation and normalization is the same code. I don't really understand the question. There isnt some special set of validators.
1 reply 0 retweets 0 likes -
Replying to @sebmck
I mean "Redundant @ in org name" is one highly specific assertion. I assume there are going to be *tons* like that soon, so my concern is around organizing them and keeping them discoverable. To be clear, I'm totally not saying specificity is a bad thing.
1 reply 0 retweets 0 likes -
Replying to @tmdpw
The validation rules aren't in separate files or even functions. The validation and normalization code is the same and everything is collocated. This is a weird case because it deals with offsets and uses a 0/1-indexed safe library.https://gist.github.com/sebmck/d601cf29070212a4b75862c9e3e0247b …
2 replies 0 retweets 0 likes -
Replying to @sebmck
Eep. I like short functions and minimal modules so I naturally assumed they'd all be decoupled. But I can see the case for both approaches.
1 reply 0 retweets 0 likes
I would not consider those functions to be long at all and there are no benefits to separation, only negatives.
-
-
Replying to @sebmck
I'll rarely write an `else if` rather than introducing some abstraction or design pattern to separate concerns. But again, not saying that's better.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 