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

Inconsistent validation for string type fields. #1541

Open
incy-tron opened this issue Jul 27, 2023 · 3 comments
Open

Inconsistent validation for string type fields. #1541

incy-tron opened this issue Jul 27, 2023 · 3 comments
Labels

Comments

@incy-tron
Copy link

I have multiple fields where the type is defined as: [string, null] some fields will allow a integer value whereas other will show a warning. For example, I have two fields defined as:

    {"title":"Os Minorversion","type":["string","null"]}
    {"title":"Os Version","type":["string","null"]}

Os Version doesn't show a warning when entering an integer, however, Os Minorversion will.

I'm using jsoneditor v9.10.2 within an Angular v14.3.0 project.

I've tried rolling back all the way to jsoneditor v9.7.4, but this issue still persists.

@josdejong
Copy link
Owner

In your screenshot, os_minorversion has a number 5 as value (colored red), and os_version is a string with value "7" (colored green). You can change between number/string via the context menu, type, auto or string.

@incy-tron
Copy link
Author

incy-tron commented Jul 27, 2023 via email

@josdejong
Copy link
Owner

josdejong commented Jul 27, 2023

It just displays what you provide it. The editor normally loads values with "auto" mode. There is only one case where it sets the value type to string and keeps it like that (until you manually change the type): when a value is a string containing a numeric value.

So if you load the following example:

{
  "os_version": "7"
}

the value of "os_version" will have type string until you manually change that.

In the following example, the type is auto:

{
  "os_version": 7
}

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

2 participants