Skip to content

Composite Schema. Error: "Cannot read property of undefined" #43

Open
@fupslot

Description

@fupslot

Validation nesting schemas throws an error if

Composite Schema

const user = schema({
  email: String
});

const querySchema = schema({
  user,
  startDate: Date,
  endDate: Date
});

Validation

await querySchema.validate({
  startDate: (new Date())
});

the object I'm passing to validate method doesn't have key user. And since user not mandatory I expect validation to pass, but instead it throws Error: Cannot read property 'email' of undefined

Is it expecting behaviour?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions