Skip to content

Error when making validation schema with array item validation #37

Closed
@funkel1989

Description

@funkel1989
  • 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?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions