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

Error when making validation schema with array item validation #37

Closed
1 task done
funkel1989 opened this issue Jul 31, 2020 · 2 comments
Closed
1 task done

Error when making validation schema with array item validation #37

funkel1989 opened this issue Jul 31, 2020 · 2 comments
Assignees
Labels

Comments

@funkel1989
Copy link

funkel1989 commented Jul 31, 2020

  • Before submitting a bug report, double-check that your Typescript version is at least 3.7.

Describe the bug
I was under the impression that that json you build for the validator was based off of AJV but i can't seem to get arrays to work the way i expect them to.

To Reproduce

const parser = new TsjsonParser(
  S({
    type: 'object',
    properties: {
      Id: S({ type: 'string' }),
      Type: S({ type: 'string', enum: ['email'] as const }),
      Message: S({ type: 'string' }),
      links: S({ type: 'array', items: [{ type: 'string' }]}),
    }
  })
);

Expected behavior
Expect the above code to be correct (assuming i'm doing everything correctly)
Actual behavior
Type '{ type: string; }' is not assignable to type 'SchemaLike'.
Object literal may only specify known properties, and 'type' does not exist in type 'Schema
Additional context
Am i just doing something wrong here or is there a bug?

@funkel1989 funkel1989 changed the title [BUG] [describe here] Error when making validation schema with array item validation Jul 31, 2020
@ostrowr
Copy link
Owner

ostrowr commented Jul 31, 2020

@funkel1989 I see you closed this; did you manage to get it working?

@funkel1989
Copy link
Author

Yes, I had a syntax error that I missed due to all of the ( and { and [ and [S({ lol. Your package is great but brackets are everywhere.
I do have another problem and once I determine its not my fault this time I'll post it. Potentially just a how-to as I can't seem to get patternProperties to work for validation with dynamic keys.

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