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

JSON Schema - Uniqueness check on property in an array of objects #1993

Closed
johnRambo2k14 opened this issue Dec 20, 2019 · 4 comments
Closed
Labels

Comments

@johnRambo2k14
Copy link

Question
Is there a way to have a uniqueness check on a property in an array of objects within an array?

for example:

 model: [
    {
        description: 'Calendars',
        id: 'Calendar',  // <--- must be unique
        type: 'object'
    },
    {
        description: 'A date which can be assigned to a calendar.',
        id: 'Date',  // <--- must be unique
        type: 'object'
    }
]
@kenisteward
Copy link
Collaborator

kenisteward commented Dec 20, 2019 via email

@johnRambo2k14
Copy link
Author

Ahh okay, can ngx-formly allow custom validation via Json schema?

Perhaps I need to do this in my custom array type component and access the model state. 🤔

@kenisteward
Copy link
Collaborator

kenisteward commented Dec 20, 2019 via email

@aitboudad
Copy link
Member

as @kenisteward pointed either use a map option (#1982 (comment)) or widget where you can pass formlyConfig:

{
  "type": ...,
  "widget": {
    "formlyConfig": {
      "wrappers": ["custom_wrapper"]
      validators: {
        validation: ['customUniqueValidation'],
      },
    }
  }
}

to define a custom validation you may check our demo example https://formly.dev/examples/validation/custom-validation

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

No branches or pull requests

3 participants