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

Provide a hook for implementing validation errors for individual tags #9

Open
danneu opened this issue Jan 19, 2015 · 3 comments
Open

Comments

@danneu
Copy link
Contributor

danneu commented Jan 19, 2015

To help users debug their BBCode markup and to generally enhance the level of error feedback, I've been validating the params and content in the openTag function of my tag specifications.

Here's an example of what I've got working:

Did you ever put any thought into this kind of feature?

I haven't studied your code too much yet, so until I figure out how it works, I threw some global state at the problem and wrote some regretful code: https://gist.github.com/danneu/f5b8b58b87b828b708bb

Obviously that's nasty and this certainly isn't a solution proposal, but it's an example of the kind of validation that would be nice to do.

As for a real solution that might be trivial, one idea off the top of my head would be to be to support an optional property on tag specs:

openTag: ...,
closeTag: ...,
// Returns String (err message) upon validation failure, else returns falsey
errorCheck: function(params, content) {
  if (!params) return 'Missing color parameter';
}

Any ideas? Either way, I'll see what kind of abstraction I end up with once I start refactoring my mess.

Also, I know this is an old project of yours, and it's possible that BBCode and this repo aren't at the forefront of your mind these days like it was back when you wrote it.

@patorjk
Copy link
Owner

patorjk commented Jan 19, 2015

Hi danneu,

I like the idea for an optional property on the tag spec to do the validating/error checking.

You're correct that it's been a while since I've taken much of a dive into this project, but I'm happy to merge in any changes you do if they look like they'll make the project better.

@xadamxk
Copy link

xadamxk commented Mar 27, 2017

Did you guys have any work for this issue/ suggestion?
I'd love to implement this into my current project.

@danneu
Copy link
Contributor Author

danneu commented Mar 27, 2017

@xadamxk I ended up implementing the sort of code I have linked in my gist, and then I never touched it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants