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

Throw error when extra fields are present #11

Open
JbIPS opened this issue Apr 11, 2017 · 1 comment
Open

Throw error when extra fields are present #11

JbIPS opened this issue Apr 11, 2017 · 1 comment

Comments

@JbIPS
Copy link
Contributor

JbIPS commented Apr 11, 2017

For now, the extractor only pluck the wanted fields and set the optional to null and the validator just check all required fields are here.

Would it be possible to throw a validation for an extra field is the validated object? Maybe add a allowsExtraFields options, default to true, in the .validate() method?

Or is it already a solution to do that? Thanks

@back2dos
Copy link
Member

You could do that, although it goes a bit against the semantics of the Haxe type system. This is valid:

var foobar:{ foo:Int, bar:Float } = { foo: 5, bar: 5.5 };
var foo:{ foo:Int } = foobar;

That said I can sort of see why rejecting extra fields might be desireable when dealing with external data. We had a similar discussion here: haxetink/tink_json#15

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

2 participants