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
606 stars 168 forks source link

Validation Bug of reqiured item #108

Open kwtsuiaa opened 6 years ago

kwtsuiaa commented 6 years ago

I used the below schema to test in http://brutusin.org/json-forms/

{
    "type": "object",
    "properties": {"prop1": {"type": "string"}},
    "required": ["prop1"]
}

Found that prop1 cannot be validated. it don't return false if I don't fill anything.

idelvall commented 6 years ago

https://github.com/brutusin/json-forms/blob/master/README.md#status

jc-src commented 6 years ago

Hello, I was also checking out this required and I found out that: 1- If you do enter some data (focus) a field then validation works. 2- if you submit without enter in a field validation is skipied and "item" is not checked.

So: https://github.com/brutusin/json-forms/blob/master/dist/js/brutusin-json-forms.js#L985 line "delete schema.required;" if that line is deleted the validation works fine.

I tried to to add to the "input" field required="required" as in theory it should work, but not. Facts are, if you do enter some data but leave a field validation works. But if you just hit validate it do not work. Soluction, comment/remove line 985 "delete schema.required"

I hope to have more time to investigate. It's a great lib, just found it) and perfect for my needs. Thanks a lot @idelvall ( Gracias!!! )