Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/metadata/ValidationMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export class ValidationMetadata {
*/
type: string;

/**
* Validator name.
*/
name?: string;

/**
* Target class to which this validation is applied.
*/
Expand Down Expand Up @@ -70,6 +75,7 @@ export class ValidationMetadata {

constructor(args: ValidationMetadataArgs) {
this.type = args.type;
this.name = args.name;
this.target = args.target;
this.propertyName = args.propertyName;
this.constraints = args?.constraints;
Expand Down
5 changes: 5 additions & 0 deletions src/metadata/ValidationMetadataArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export interface ValidationMetadataArgs {
*/
type: string;

/**
* Validator name.
*/
name?: string;

/**
* Object that is used to be validated.
*/
Expand Down
1 change: 1 addition & 0 deletions src/register-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export function registerDecorator(options: ValidationDecoratorOptions): void {

const validationMetadataArgs: ValidationMetadataArgs = {
type: options.name && ValidationTypes.isValid(options.name) ? options.name : ValidationTypes.CUSTOM_VALIDATION,
name: options.name,
target: options.target,
propertyName: options.propertyName,
validationOptions: options.options,
Expand Down
5 changes: 5 additions & 0 deletions src/validation-schema/ValidationSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export interface ValidationSchema {
*/
type: string;

/**
* Validator name.
*/
name?: string;

/**
* Constraints set by validation type.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class ValidationSchemaToMetadataTransformer {
};
const args: ValidationMetadataArgs = {
type: validation.type,
name: validation.name,
target: schema.name,
propertyName: property,
constraints: validation.constraints,
Expand Down