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

onlyAvailableItems is not a property of ValidateOptions #5545

Open
LoLei opened this issue Mar 22, 2024 · 0 comments
Open

onlyAvailableItems is not a property of ValidateOptions #5545

LoLei opened this issue Mar 22, 2024 · 0 comments

Comments

@LoLei
Copy link

LoLei commented Mar 22, 2024

Describe the bug
A clear and concise description of what the bug is.

When using https://formio.github.io/formio.js/app/builder, you can enable onlyAvailableItems on a select component like this:

    "components": [
        {
            "label": "Select",
            "widget": "choicesjs",
            "tableView": true,
            "validate": {
                "onlyAvailableItems": true  //  <--- Here
            },
            "key": "select",
            "type": "select",
            "input": true
        }
    ]

However, when using the JS (TS) library, I cannot do the same, e.g.:

  const form: FormioForm = {
    components: [
      {
        label: 'Select',
        widget: 'choicesjs',
        tableView: true,
        validate: {
          onlyAvailableItems: true  // <--- Typescript error see below
        },
        key: 'select',
        type: 'select',
        input: true
      }
    ]
  }
Object literal may only specify known properties, and 'onlyAvailableItems' does not exist in type 'ValidateOptions'.ts(2353)
schema.d.ts(82, 3): The expected type comes from property 'validate' which is declared here on type 'ExtendedComponentSchema'

If I view the definition of ValidateOptions, I can see that onlyAvailableItems does not exist.

export interface ValidateOptions {

Version/Branch
What release version or branch are you experiencing the behavior

4.19.x

To Reproduce
Steps to reproduce the behavior:

  1. Create Typescript variable using FormioForm as a type.
  2. Add component based on the typescript code posted above.
  3. See error

Expected behavior
A clear and concise description of what you expected to happen.

The error should not occur and the property should exist on the interface, as would be expected due to it being accepted in the JSON.

Additional context

If I'm doing something wrong, or my understanding is incorrect, please let me know, of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant