import { Type } from '@mikro-orm/core'; import { Constructor } from '@mikro-orm/core/typings'; import { PipeTransform } from '@nestjs/common'; import { ApiPropertyOptions } from '@nestjs/swagger'; import { ValidatorConstraintInterface } from 'class-validator'; /** * Factory function to create a new NominalTypeClass. * This is a basic fabric for creating nominal types. * * Usage: * ``` * class EmailValidator implements ValidatorConstraintInterface { * public validate(value: any, validationArguments?: ValidationArguments) { * return isEmail(value); * } * * public defaultMessage(validationArguments?: ValidationArguments) { * return `${validationArguments.value} is not E-Mail.`; * } * } * * export class Email extends NType({ name: 'email' }) { * protected _nominalType = Email.name; * } * ``` * * You can add additional methods to `Email` class to work with email data type * * @param options - Options to configure the nominal type * @param options.name - A string representing the name of the nominal type * @param options.validator - A validator constructor for the nominal type * @constructor */ export declare const NType: (options: { name: Name; validator?: Constructor; }) => (abstract new (value: any) => { /** * Property used to make incompatible different types * @internal */ readonly "__#2@#_nominalType": Name; readonly value: any; toString(): any; toJSON(): any; /** * Checks if two values of the nominal type are identical. * * @param value - The value to compare with the current instance value. * @returns Returns `true` if the values are identical, `false` otherwise. */ isIdentical(value: any): boolean; }) & { readonly apiPropertyOptions: ApiPropertyOptions; /** * Returns the ORM type for this nominal type. * * @returns A constructor for the ORM type. */ getOrmType(): Constructor>; /** * Returns the validator constructor for this nominal type. * * todo: probably can be protected * * @throws An exception if the validator is not defined. * @returns The validator constructor for this nominal type. */ getValidator(): Constructor; /** * Basic implementation of resource decorator. Can be inherited */ getResourceDecorators(...args: any[]): (target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor) => void; /** * Get pipe for NestJS to convert incoming params into class instantly */ getPipe(): PipeTransform; createInstance(this: new (...args: any[]) => T, ...args: any[]): T; };