brutusin / json-forms

JSON Schema to HTML form generator, supporting dynamic subschemas (on the fly resolution). Extensible and customizable library with zero dependencies. Bootstrap add-ons provided
http://brutusin.org/json-forms
Apache License 2.0
607 stars 168 forks source link

Validation is not working if form is not filled #95

Open sandeepbhatt opened 7 years ago

sandeepbhatt commented 7 years ago

Hi , I am using brutusin:json-forms in my project to create form dynamically. But I have found one issue with validation. If form is empty then validation is not working for below json JSON Data=>

{
"title": "Person",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}

Please help me to fix this issue.

fabifabi commented 7 years ago

if empty,the required fields are not okay,so it can't validate ?!? i didn't understood?

sandeepbhatt commented 7 years ago

Validation is not working if no fields are filled in the form. the form is generated through above JSON schema in http://brutusin.org/json-forms/.

sandeepbhatt commented 7 years ago

Hi,

Any Update ??

geoshar commented 7 years ago

just happened it to me, fixed! just find that line if (parentObject[prop] !== null) { replace with if (parentObject[prop] == null) { and it will work, cheers!