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

Validate require, minOccurs, maxOccurs #103

Closed
xoob opened this issue Oct 9, 2015 · 5 comments
Closed

Validate require, minOccurs, maxOccurs #103

xoob opened this issue Oct 9, 2015 · 5 comments
Assignees
Labels
Milestone

Comments

@xoob
Copy link

xoob commented Oct 9, 2015

Great to see occurence support added in #101.

It would be good if jsonix could validate that required fields are present when unmarshalling an XML document. If a required field is missing, jsonix should throw an error.

This is already done for other things, like enum values: https://github.com/highsource/jsonix/blob/master/nodejs/scripts/jsonix.js#L2667

@highsource
Copy link
Owner

I'm a bit sceptic about validation. Enums were required because they can't
be typesafely converted otherwise.

But validating occurence or facets would probably go to far, it is from my
point of view not really the scope of Jsonix.

In this case I think it woule be better to generate a JSON Schema and to
validate JSON against that schema using a JSON Schema validator like AJV.
What do you think?

On Fri, Oct 9, 2015 at 8:57 PM, Alex Brausewetter [email protected]
wrote:

Great to see occurence support added in #101
#101.

It would be good if jsonix could validate that required fields are present
when unmarshalling an XML document. If a required field is missing, jsonix
should throw an error.

This is already done for other things, like enum values:
https://github.com/highsource/jsonix/blob/master/nodejs/scripts/jsonix.js#L2667


Reply to this email directly or view it on GitHub
#103.

@highsource highsource added this to the 2.3.x milestone Dec 7, 2015
@highsource highsource self-assigned this Dec 7, 2015
@highsource
Copy link
Owner

Closing as wontfix as validation is not in the scope of Jsonix.

@ainthek
Copy link

ainthek commented Dec 16, 2016

if validation is out of scope what is the purpose of required property inside typeInfos ?
propertyInfos: [{
name: 'contractStateCode',
required: true,
elementName: 'ContractStateCode',
typeInfo: 'Token'
}, {

thanx

@highsource
Copy link
Owner

Some folks use this information for tasks like UI generation. This required attribute is provided by the underlying schema model libs so it's easy to generate. But Jsonix has never had validation in the scope.

@ainthek
Copy link

ainthek commented Dec 20, 2016

So ma it VERY clear in docs at least. To avoid more of us confused users.
Thanx man

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

No branches or pull requests

3 participants