Skip to content

question: if one project have two instance of class-validator, they cannot validate each other. #184

@XGHeaven

Description

@XGHeaven

here is an example, project structure looks like this

- node_modules
  - some-package
    - node_modules
      - class-validator (instance 1)
  - class-validator (instance 2)
- app.ts

package-a provide some function to validate class powered by class-validator.

// package-a
import {validate} from 'class-validator' // use instance 1
export const someValidate = validate
// app.ts
import {someValidate} from 'some-package'
import {validate, IsInt} from 'class-validator' // use instance 2

class A {
  @IsInt()
  name: string
}

const a = new A()
a.name = 'test'

validate(a).then(console.log) // get errors
someValidate(a).then(console.log) // no errors

How to solve this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionQuestions about the usage of the library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions