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

default requirement of valid object keys within array? #486

Closed
raza2022 opened this issue Jun 11, 2023 · 2 comments
Closed

default requirement of valid object keys within array? #486

raza2022 opened this issue Jun 11, 2023 · 2 comments

Comments

@raza2022
Copy link

raza2022 commented Jun 11, 2023

Hi dev, thanks for a great package, however, I want to confirm one thing about the requirement of nested object keys ([object])
let's see my use case
there should be one object existing for that array else it will throw an error but I am surprised that if I passed the empty array [] it validates it too, I see some other way to validate object keys but my general assumption is
all keys defined within the object should be validated unless passed the {optional:true}

new SimpleSchema({
        'plan.bonuses': {
            type: Array,
        },
        'plan.bonuses.$': Object,
        'plan.bonuses.$.title': {
            type: String,
        },
    })

so I want it will only validate if I pass the array with at least one object else throw error on []

bonuses: [{
title: 'test'
}]
@github-actions
Copy link

Thank you for submitting an issue!

If this is a bug report, please be sure to include, at minimum, example code showing a small schema and any necessary calls with all their arguments, which will reproduce the issue. Even better, you can link to a saved online code editor example, where anyone can immediately run the code and see the issue.

If you are requesting a feature, include a code example of how you imagine it working if it were implemented.

If you need to edit your issue description, click the [...] and choose Edit.

Be patient. This is a free and freely licensed package that I maintain in my spare time. You may get a response in a day, but it could also take a month. If you benefit from this package and would like to see more of my time devoted to it, you can help by sponsoring.

@raza2022
Copy link
Author

sorry it's very simple maybe I missed it because of working at night it was simply solved by minCount as at first read I thought it was only for singular values, now it's solved like below

bonuses: {
        type: Array,
        minCount: 1,
    },

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