# Source: https://mikro-orm.io/api/core/class/ValidationError.md

# ValidationError<!-- --> \<T>

### Hierarchy

* Error

  * *ValidationError*

    * [CursorError](https://mikro-orm.io/api/core/class/CursorError.md)
    * [OptimisticLockError](https://mikro-orm.io/api/core/class/OptimisticLockError.md)
    * [MetadataError](https://mikro-orm.io/api/core/class/MetadataError.md)
    * [NotFoundError](https://mikro-orm.io/api/core/class/NotFoundError.md)
    * [TransactionStateError](https://mikro-orm.io/api/core/class/TransactionStateError.md)

## Index[**](#Index)

### Constructors

* [**constructor](#constructor)

### Properties

* [**cause](#cause)
* [**entity](#entity)
* [**message](#message)
* [**name](#name)
* [**stack](#stack)
* [**stackTraceLimit](#stackTraceLimit)

### Methods

* [**getEntity](#getEntity)
* [**cannotCommit](#cannotCommit)
* [**cannotModifyInverseCollection](#cannotModifyInverseCollection)
* [**cannotModifyReadonlyCollection](#cannotModifyReadonlyCollection)
* [**cannotRemoveFromCollectionWithoutOrphanRemoval](#cannotRemoveFromCollectionWithoutOrphanRemoval)
* [**cannotUseGlobalContext](#cannotUseGlobalContext)
* [**cannotUseGroupOperatorsInsideScalars](#cannotUseGroupOperatorsInsideScalars)
* [**cannotUseOperatorsInsideEmbeddables](#cannotUseOperatorsInsideEmbeddables)
* [**captureStackTrace](#captureStackTrace)
* [**entityNotManaged](#entityNotManaged)
* [**fromCollectionNotInitialized](#fromCollectionNotInitialized)
* [**fromMergeWithoutPK](#fromMergeWithoutPK)
* [**fromWrongPropertyType](#fromWrongPropertyType)
* [**fromWrongRepositoryType](#fromWrongRepositoryType)
* [**invalidCompositeIdentifier](#invalidCompositeIdentifier)
* [**invalidEmbeddableQuery](#invalidEmbeddableQuery)
* [**invalidPropertyName](#invalidPropertyName)
* [**invalidType](#invalidType)
* [**notDiscoveredEntity](#notDiscoveredEntity)
* [**notEntity](#notEntity)
* [**prepareStackTrace](#prepareStackTrace)
* [**propertyRequired](#propertyRequired)
* [**transactionRequired](#transactionRequired)

## Constructors<!-- -->[**](#Constructors)

### [**](#constructor)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L6)constructor

* ****new ValidationError**\<T>(message, entity): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<T>

- Overrides Error.constructor

  #### Parameters

  * ##### message: string
  * ##### optionalentity: T

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<T>

## Properties<!-- -->[**](#Properties)

### [**](#cause)[**](https://undefined/mikro-orm/mikro-orm/blob/master/docs/node_modules/typescript/src/lib.es2022.error.d.ts#L26)optionalinheritedcause

**cause?

<!-- -->

: unknown

Inherited from Error.cause

### [**](#entity)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L6)optionalreadonlyentity

**entity?

<!-- -->

: T

### [**](#message)[**](https://undefined/mikro-orm/mikro-orm/blob/master/docs/node_modules/typescript/src/lib.es5.d.ts#L1077)inheritedmessage

**message: string

Inherited from Error.message

### [**](#name)[**](https://undefined/mikro-orm/mikro-orm/blob/master/docs/node_modules/typescript/src/lib.es5.d.ts#L1076)inheritedname

**name: string

Inherited from Error.name

### [**](#stack)[**](https://undefined/mikro-orm/mikro-orm/blob/master/docs/node_modules/typescript/src/lib.es5.d.ts#L1078)optionalinheritedstack

**stack?

<!-- -->

: string

Inherited from Error.stack

### [**](#stackTraceLimit)[**](https://undefined/mikro-orm/mikro-orm/blob/master/node_modules/@types/node/globals.d.ts#L68)staticinheritedstackTraceLimit

**stackTraceLimit: number

Inherited from Error.stackTraceLimit

The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`).

The default value is `10` but may be set to any valid JavaScript number. Changes will affect any stack trace captured *after* the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will not capture any frames.

## Methods<!-- -->[**](#Methods)

### [**](#getEntity)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L17)getEntity

* ****getEntity**(): undefined | Partial\<any>

- Gets instance of entity that caused this error.

  ***

  #### Returns undefined | Partial\<any>

### [**](#cannotCommit)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L116)staticcannotCommit

* ****cannotCommit**(): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#cannotModifyInverseCollection)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L90)staticcannotModifyInverseCollection

* ****cannotModifyInverseCollection**(owner, property): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### owner: Partial\<any>
  * ##### property: [EntityProperty](https://mikro-orm.io/api/core/interface/EntityProperty.md)\<any, any>

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#cannotModifyReadonlyCollection)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L99)staticcannotModifyReadonlyCollection

* ****cannotModifyReadonlyCollection**(owner, property): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### owner: Partial\<any>
  * ##### property: [EntityProperty](https://mikro-orm.io/api/core/interface/EntityProperty.md)\<any, any>

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#cannotRemoveFromCollectionWithoutOrphanRemoval)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L103)staticcannotRemoveFromCollectionWithoutOrphanRemoval

* ****cannotRemoveFromCollectionWithoutOrphanRemoval**(owner, property): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### owner: Partial\<any>
  * ##### property: [EntityProperty](https://mikro-orm.io/api/core/interface/EntityProperty.md)\<any, any>

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#cannotUseGlobalContext)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L120)staticcannotUseGlobalContext

* ****cannotUseGlobalContext**(): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#cannotUseGroupOperatorsInsideScalars)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L128)staticcannotUseGroupOperatorsInsideScalars

* ****cannotUseGroupOperatorsInsideScalars**(className, propName, payload): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### className: string
  * ##### propName: string
  * ##### payload: unknown

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#cannotUseOperatorsInsideEmbeddables)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L124)staticcannotUseOperatorsInsideEmbeddables

* ****cannotUseOperatorsInsideEmbeddables**(className, propName, payload): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### className: string
  * ##### propName: string
  * ##### payload: unknown

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#captureStackTrace)[**](https://undefined/mikro-orm/mikro-orm/blob/master/node_modules/@types/node/globals.d.ts#L52)staticinheritedcaptureStackTrace

* ****captureStackTrace**(targetObject, constructorOpt): void

- Inherited from Error.captureStackTrace

  Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()` was called.

  ```
  const myObject = {};
  Error.captureStackTrace(myObject);
  myObject.stack;  // Similar to `new Error().stack`
  ```

  The first line of the trace will be prefixed with `${myObject.name}: ${myObject.message}`.

  The optional `constructorOpt` argument accepts a function. If given, all frames above `constructorOpt`, including `constructorOpt`, will be omitted from the generated stack trace.

  The `constructorOpt` argument is useful for hiding implementation details of error generation from the user. For instance:

  ```
  function a() {
    b();
  }

  function b() {
    c();
  }

  function c() {
    // Create an error without stack trace to avoid calculating the stack trace twice.
    const { stackTraceLimit } = Error;
    Error.stackTraceLimit = 0;
    const error = new Error();
    Error.stackTraceLimit = stackTraceLimit;

    // Capture the stack trace above function b
    Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
    throw error;
  }

  a();
  ```

  ***

  #### Parameters

  * ##### targetObject: object
  * ##### optionalconstructorOpt: Function

  #### Returns void

### [**](#entityNotManaged)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L49)staticentityNotManaged

* ****entityNotManaged**(entity): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### entity: Partial\<any>

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#fromCollectionNotInitialized)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L34)staticfromCollectionNotInitialized

* ****fromCollectionNotInitialized**(entity, prop): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### entity: Partial\<any>
  * ##### prop: [EntityProperty](https://mikro-orm.io/api/core/interface/EntityProperty.md)\<any, any>

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#fromMergeWithoutPK)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L41)staticfromMergeWithoutPK

* ****fromMergeWithoutPK**(meta): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### meta: [EntityMetadata](https://mikro-orm.io/api/core/class/EntityMetadata.md)\<any>

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#fromWrongPropertyType)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L21)staticfromWrongPropertyType

* ****fromWrongPropertyType**(entity, property, expectedType, givenType, givenValue): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### entity: Partial\<any>
  * ##### property: string
  * ##### expectedType: string
  * ##### givenType: string
  * ##### givenValue: string

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#fromWrongRepositoryType)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L28)staticfromWrongRepositoryType

* ****fromWrongRepositoryType**(entityName, repoType, method): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### entityName: string
  * ##### repoType: string
  * ##### method: string

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#invalidCompositeIdentifier)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L112)staticinvalidCompositeIdentifier

* ****invalidCompositeIdentifier**(meta): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### meta: [EntityMetadata](https://mikro-orm.io/api/core/class/EntityMetadata.md)\<any>

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#invalidEmbeddableQuery)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L132)staticinvalidEmbeddableQuery

* ****invalidEmbeddableQuery**(className, propName, embeddableType): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### className: string
  * ##### propName: string
  * ##### embeddableType: string

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#invalidPropertyName)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L71)staticinvalidPropertyName

* ****invalidPropertyName**(entityName, invalid): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### entityName: string
  * ##### invalid: string

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#invalidType)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L75)staticinvalidType

* ****invalidType**(type, value, mode): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### type: [Constructor](https://mikro-orm.io/api/core.md#Constructor)\<any>
  * ##### value: any
  * ##### mode: string

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#notDiscoveredEntity)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L58)staticnotDiscoveredEntity

* ****notDiscoveredEntity**(data, meta, action): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### data: any
  * ##### optionalmeta: [EntityMetadata](https://mikro-orm.io/api/core/class/EntityMetadata.md)\<any>
  * ##### action: string = <!-- -->'persist'

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#notEntity)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L53)staticnotEntity

* ****notEntity**(owner, prop, data): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### owner: Partial\<any>
  * ##### prop: [EntityProperty](https://mikro-orm.io/api/core/interface/EntityProperty.md)\<any, any>
  * ##### data: any

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#prepareStackTrace)[**](https://undefined/mikro-orm/mikro-orm/blob/master/node_modules/@types/node/globals.d.ts#L56)staticinheritedprepareStackTrace

* ****prepareStackTrace**(err, stackTraces): any

- Inherited from Error.prepareStackTrace

  * **@see**

    <https://v8.dev/docs/stack-trace-api#customizing-stack-traces>

  ***

  #### Parameters

  * ##### err: Error
  * ##### stackTraces: CallSite\[]

  #### Returns any

### [**](#propertyRequired)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L85)staticpropertyRequired

* ****propertyRequired**(entity, property): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Parameters

  * ##### entity: Partial\<any>
  * ##### property: [EntityProperty](https://mikro-orm.io/api/core/interface/EntityProperty.md)\<any, any>

  #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

### [**](#transactionRequired)[**](https://github.com/mikro-orm/mikro-orm/blob/master/packages/core/src/errors.ts#L45)statictransactionRequired

* ****transactionRequired**(): [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>

- #### Returns [ValidationError](https://mikro-orm.io/api/core/class/ValidationError.md)\<Partial\<any>>