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

Conditional selection fails silently if not validated #71

Open
heggemsnes opened this issue Feb 20, 2023 · 2 comments
Open

Conditional selection fails silently if not validated #71

heggemsnes opened this issue Feb 20, 2023 · 2 comments

Comments

@heggemsnes
Copy link
Contributor

Hi!

I found an issue when using the amazing conditional grab:

// If title is null it fails silently here
const schema = q("*")
  .filter()
  .grab(
    {
      _id: q.string(),
    },
    {
      "type == 'page'": {
        _type: q.literal("page"),
        title: q.string(),
      },
    }
  )

// If title is null the validation fails with an error message
const schema = q("*")
  .filter()
  .grab(
    {
      _id: q.string(),
      title: q.string()
    },
   
  )

Everything works as expected if title is a string as expected, but if it's null the validation fails silently and the parse only returns the _id field.

Would be great if an error message would show up here as well!

@iduuck
Copy link
Collaborator

iduuck commented Feb 23, 2023

I have the same error, looking into this later and doing a PR, when I find time!

@gksander
Copy link
Contributor

I started this branch a month ago and haven't gotten around to finishing that up, but you might use that as a starting point!

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

3 participants