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

Ignore unrecognized fields #21

Closed
darcling opened this issue May 29, 2015 · 2 comments · Fixed by #24
Closed

Ignore unrecognized fields #21

darcling opened this issue May 29, 2015 · 2 comments · Fixed by #24

Comments

@darcling
Copy link

I forked you to add the option to ignore unrecognized fields because my UI framework adds some but my Node.js API doesn't need to care. But, while reading through your code I noticed that I can get effectively the same results by instantiating my validator with a null second parameter (existing_error) :
new FieldVal(input, null);

But, I think that's just a coincidence since it still does unrecognized logic checking in generate_response().

I took a quick stab at accepting options without breaking backwards compatibility over here :
darcling@76cfc05
But I only added the 'ignore unrecognized fields' option because that's what I needed : )

You may have a better way.

Thanks for the library by the way, I'm just getting rolling with it.

@MarcusLongmuir
Copy link
Contributor

Hey @darcling. I hope the library is useful.

I looked at your change and decided the best approach was to change the constructor to accommodate options as the second (optional) argument. The existing_error argument can now be supplied using the "error" property in the options. I've also added support for your additional functionality, "ignore_unrecognized". These changes are currently on the develop_options branch (60a137b). I'll merge them into a release soon if I find no severe issues with projects this library is being used in.

new FieldVal(my_data,{
    "error": my_existing_error,
    "ignore_unrecognized": true
});

@darcling
Copy link
Author

Thanks Marcus, I'll give it a try as soon as I can circle back - probably Monday.

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

Successfully merging a pull request may close this issue.

2 participants