Skip to content

Code breaking change in 2.2.10 - modelClass is now required on ValidationError arguments #1986

@dryu

Description

@dryu

So, just to give you a bit of an update, I'm using a Typescript, and my code was like this :

new objection.ValidationError({
    message: "...",
    type: "...",
    data: {...}
});

This is how it is mentioned in the documentation for the custom validation by the way.

Before 2.2.10 everything was fine, but now ValidationError requires a modelClass argument and without it Typescript compilation fails with the error about a missing required param.

I had to add this param to make builds work.

The new code may work with a pure JS, but it is Typescript compilation that is a problem, because the arguments for ValidationError now includes & {modelClass: ModelClass<Model>} which wasn't there before.

It is unexpected to encounter a code breaking change in the patch release, since most of us has the dependency specified as something like this: "objection": "^2.2.3", which will install the latest patch version by default.

Originally posted by @dryu in #1891 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions