Commit d56f2dda authored by FORESTIER Fabien's avatar FORESTIER Fabien
Browse files

Fix validation on links array

parent fb8bed58
Pipeline #2353 passed with stages
in 24 seconds
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger';
import { IsArray, IsBoolean, IsOptional, IsString, MaxLength } from 'class-validator';
import { Type } from 'class-transformer';
import { IsArray, IsBoolean, IsOptional, IsString, MaxLength, ValidateNested } from 'class-validator';
import { Link } from '../links/link.dto';
import { Organization } from './organization.entity';
......@@ -29,10 +30,12 @@ export class OrganizationDTO {
@IsString()
logo?: string;
@ApiModelPropertyOptional({ type: [Link] })
@ApiModelPropertyOptional({ type: Link, isArray: true })
@IsOptional()
@IsArray()
links?: [Link];
@ValidateNested({ each: true })
@Type(() => Link)
links?: Link[];
@ApiModelProperty()
@IsBoolean()
......
import { ApiModelProperty } from '@nestjs/swagger';
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger';
import { IsBoolean } from 'class-validator';
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { LinkEntity } from '../links/link.entity';
......@@ -30,7 +30,7 @@ export class Organization {
eager: true,
cascade: true,
})
@ApiModelProperty()
@ApiModelPropertyOptional()
links: LinkEntity[];
@Column('text', { nullable: true })
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment