Skip to content
Snippets Groups Projects
Commit 953e6899 authored by Steffen Schulze's avatar Steffen Schulze
Browse files

Merge branch 'fix/did-creation-validation' into 'main'

fix did registration validation

See merge request !48
parents 611f68a0 ddcd83ab
No related branches found
No related tags found
1 merge request!48fix did registration validation
Pipeline #41204 canceled
...@@ -35,18 +35,24 @@ export class DIDsService { ...@@ -35,18 +35,24 @@ export class DIDsService {
seed: EventDidsRegisterIndyFromSeedInput['seed'], seed: EventDidsRegisterIndyFromSeedInput['seed'],
services?: Array<{ id: string; type: string; serviceEndpoint: string }>, services?: Array<{ id: string; type: string; serviceEndpoint: string }>,
) { ) {
const mappedServices: EventDidsRegisterIndyFromSeedInput['services'] = const data: EventDidsRegisterIndyFromSeedInput = { tenantId, seed };
services?.map(({ id, type, serviceEndpoint }) => ({
identifier: id, if (services && services.length > 0) {
type, const mappedServices: EventDidsRegisterIndyFromSeedInput['services'] =
url: serviceEndpoint, services?.map(({ id, type, serviceEndpoint }) => ({
})); identifier: id,
type,
url: serviceEndpoint,
}));
data.services = mappedServices;
}
return this.natsClient return this.natsClient
.send< .send<
EventDidsRegisterIndyFromSeed, EventDidsRegisterIndyFromSeed,
EventDidsRegisterIndyFromSeedInput EventDidsRegisterIndyFromSeedInput
>(EventDidsRegisterIndyFromSeed.token, { tenantId, seed, services: mappedServices }) >(EventDidsRegisterIndyFromSeed.token, data)
.pipe(map(({ data }) => data)); .pipe(map(({ data }) => data));
} }
......
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer'; import { Type } from 'class-transformer';
import { IsArray, IsOptional, IsString, ValidateNested } from 'class-validator'; import {
IsArray,
IsNotEmpty,
IsOptional,
IsString,
ValidateNested,
} from 'class-validator';
class Service { class Service {
@IsString() @IsString()
...@@ -34,6 +40,7 @@ export class RegisterFromSeedPayload { ...@@ -34,6 +40,7 @@ export class RegisterFromSeedPayload {
public seed: string; public seed: string;
@IsArray() @IsArray()
@IsNotEmpty()
@ValidateNested() @ValidateNested()
@Type(() => Service) @Type(() => Service)
@IsOptional() @IsOptional()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment