|
1 | | -import {Injectable, Logger, OnApplicationBootstrap} from '@nestjs/common'; |
| 1 | +import {BadRequestException, Injectable, Logger, OnApplicationBootstrap} from '@nestjs/common'; |
2 | 2 | import {parse} from 'yaml'; |
3 | 3 | import {existsSync, readFileSync, readdirSync, writeFileSync} from 'fs'; |
4 | 4 | import {ConfigObjectSchemaDTO} from './_dto/config.dto'; |
@@ -96,6 +96,10 @@ export class IdentitiesValidationService implements OnApplicationBootstrap { |
96 | 96 | public async transformAttribute(key: string, attribute: any, data: any) { |
97 | 97 |
|
98 | 98 | const path = this.resolveConfigPath(key); |
| 99 | + if (path === null){ |
| 100 | + this.logger.error('schema for ' + key + ' does not exist'); |
| 101 | + throw new BadRequestException('schema for ' + key + ' does not exist'); |
| 102 | + } |
99 | 103 | const schema: any = parse(readFileSync(path, 'utf8')); |
100 | 104 | this.logger.debug(`Additionalfields object transformation: ${JSON.stringify(data[key])}`); |
101 | 105 | for (const [index, def] of Object.entries(schema?.properties || {})) { |
@@ -245,6 +249,10 @@ export class IdentitiesValidationService implements OnApplicationBootstrap { |
245 | 249 | */ |
246 | 250 | public async validateAttribute(key: string, attribute: any, data: any): Promise<any | null> { |
247 | 251 | const path = this.resolveConfigPath(key); |
| 252 | + if (path === null) { |
| 253 | + this.logger.error('schema for ' + key + ' does not exist'); |
| 254 | + throw new BadRequestException('schema for ' + key + ' does not exist'); |
| 255 | + } |
248 | 256 | const schema: any = parse(readFileSync(path, 'utf8')); |
249 | 257 |
|
250 | 258 | for (const [index, def] of Object.entries(schema?.properties || {})) { |
|
0 commit comments