Closed ayhlam closed 7 years ago
Hi @ayhlam, thanks for your interest in ASF and thanks for your very detailed issue. It's great when people provide examples like this as it ensures there is no confusion.
The behaviour you are seeing is correct and there is no bug here. The schema defines the data model, structure, data types and validation. The form defines the UI. You can put a select (enum) on a schema data type "string" as the option selected is stored in the model as a string. But you cannot put a number input field on a schema data type "string" as they are different data types. You should use the "number" or "integer" type in your schema.
@ayhlam I agree, nice work on the issue, we appreciate it despite the resolution :)
Please re-open if you do not feel the question has been answered sufficiently.
Bug
As a user/developer, when I set the schema of type of a field to be a string, then set the type to be a number in the form, then the generated input box should work completely as a number box. This is similar to the way the form can treat enums.
Expected behaviour
Similar to changing the form to
type="select"
, changing the form totype="number"
should allow the user to input numbers and integers even though the schema hastype="string"
.Actual behaviour
It returns an error
Invalid type, expected string
Gist/Plunker/Demo
Demonstrate expected behavior with
type="select"
form andtype="string"
schemaDemonstrate error with
type="number"
form andtype="string"
schema@json-schema-form/angular-schema-form-lead