@mikro-orm/core
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
74 lines (73 loc) • 3.33 kB
TypeScript
import type { EntityMetadata, EntityName } from '../typings.js';
import type { Routine } from './Routine.js';
import { type MetadataDiscoveryOptions } from '../utils/Configuration.js';
import type { MetadataStorage } from './MetadataStorage.js';
/**
* @internal
*/
export declare class MetadataValidator {
validateEntityDefinition<T>(metadata: MetadataStorage, name: EntityName<T>, options: MetadataDiscoveryOptions): void;
validateRoutineDefinition(routine: Routine): void;
validateDiscovered(discovered: EntityMetadata[], options: MetadataDiscoveryOptions): void;
private validatePartitioning;
/**
* Find the first partition name whose normalized form (case-folded for unquoted segments,
* quoted segments preserved) has already been seen. Returns the offending name in its
* original form for the error message.
*/
private findDuplicatePartitionName;
/**
* Partition names may be bare (`child`), schema-qualified (`schema.child`), or use quoted
* identifiers (`"my.schema"."child"`). Reject anything with more than one unquoted `.`.
*/
private hasValidPartitionName;
private hasPartitionExpression;
private validatePartitionKeyConstraints;
/**
* Returns the list of physical field names that a partition expression references, or
* `undefined` when the expression is opaque (callback, or raw SQL like `date_trunc('day', x)`
* that we cannot statically parse). Opaque expressions intentionally bypass the primary-key /
* unique-constraint coverage checks — users are trusted to ensure the referenced columns are
* part of the partition key, since PostgreSQL will surface the violation at DDL execution.
*/
private getPartitionKeyFields;
private resolvePartitionKeyField;
private getConstraintFields;
private validateReference;
private validateTargetKey;
/**
* Checks if a property has a unique constraint (either via `unique: true` or single-property `@Unique` decorator).
* Composite unique constraints are not sufficient for targetKey.
*/
private isPropertyUnique;
private validatePolymorphicTargets;
private validateBidirectional;
private validateOwningSide;
private validateInverseSide;
private validateIndexes;
private validateDuplicateFieldNames;
private validateVersionField;
/**
* Validates that entity properties do not use dangerous names that could lead to
* prototype pollution vulnerabilities. This validation ensures that property names
* cannot be exploited to modify object prototypes when values are assigned during
* entity hydration or persistence operations.
*
* @internal
*/
private validatePropertyNames;
/**
* Validates view entity configuration.
* View entities must have an expression.
*/
private validateViewEntity;
/**
* Validates that STI and TPT are not mixed in the same inheritance hierarchy.
* An entity hierarchy can use either STI (discriminatorColumn) or TPT (inheritance: 'tpt'),
* but not both.
*
* Note: This validation runs before `initTablePerTypeInheritance` sets `inheritanceType`,
* so we check the raw `inheritance` option from the decorator/schema.
*/
private validateInheritanceStrategies;
}