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

"any" type properties are never valid #81

Closed joguiMultimedia closed 7 years ago

joguiMultimedia commented 7 years ago

Using the the "Simple" example and changing the property type to "any" displays a textarea control which is OK. As long as the input is empty the validation passes but inserting any text/number throws a validation error. Is this the intent? what content should be entered in "any" field?

{
  "$schema": "http://json-schema.org/draft-03/schema#",
  "title": "A boolean",
  "description": "A simple boolean data type as schema root",
  "type": "any"
}
joguiMultimedia commented 7 years ago

EDIT: adding double quotes passes the validation. single quotes no. Maybe a parsing artefact?

idelvall commented 7 years ago

Hi @joguiMultimedia. I can't reproduce the issue. What dta are you inputing? What browser are you using?

joguiMultimedia commented 7 years ago

using chrome/chromium. any text is invalid unless surrounding it with double quotes. Maybe chrome textarea have a strange way of returning the data... EDIT2: simple quotes workaround it as weel. EDIT3: without quotes the returned data is null

joguiMultimedia commented 7 years ago

reproduced with firefox 53.0 as well. Same behaviour, data is null without quotes.

joguiMultimedia commented 7 years ago

When using initial data to fill the field, the textarea content shows the quotes.

idelvall commented 7 years ago

that is the expected behaviour. "any" here mens any schema type (number, boolean, object, array...), not any string. The value to enter in the text area must be a valid JSON expression

joguiMultimedia commented 7 years ago

OK, I got it. I will use a decorator to enter a free text, arbitrarily sized in a textarea. Unless there is another preexisting solution?

joguiMultimedia commented 7 years ago

Thanks for quick reply.

idelvall commented 7 years ago

Yes, thereis a better way for this. http://brutusin.org/json-forms/#8

joguiMultimedia commented 7 years ago

I missed that. thanks.