update
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import { ValidationError } from '../errors/base.errors.js';
|
||||
import type { IBaseConfig } from './base.config.js';
|
||||
|
||||
/**
|
||||
* Validation result
|
||||
@ -95,56 +94,6 @@ export type ValidationSchema = Record<string, {
|
||||
* Validates configuration objects against schemas and provides default values
|
||||
*/
|
||||
export class ConfigValidator {
|
||||
/**
|
||||
* Basic schema for IBaseConfig
|
||||
*/
|
||||
private static baseConfigSchema: ValidationSchema = {
|
||||
id: {
|
||||
type: 'string',
|
||||
required: false
|
||||
},
|
||||
version: {
|
||||
type: 'string',
|
||||
required: false
|
||||
},
|
||||
environment: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
enum: ['development', 'test', 'staging', 'production'],
|
||||
default: 'production'
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: false
|
||||
},
|
||||
enabled: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
default: true
|
||||
},
|
||||
logging: {
|
||||
type: 'object',
|
||||
required: false,
|
||||
schema: {
|
||||
level: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
enum: ['error', 'warn', 'info', 'debug'],
|
||||
default: 'info'
|
||||
},
|
||||
structured: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
default: true
|
||||
},
|
||||
correlationTracking: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
default: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Validate a configuration object against a schema
|
||||
@ -261,15 +210,6 @@ export class ConfigValidator {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate base configuration
|
||||
*
|
||||
* @param config Base configuration
|
||||
* @returns Validation result for base configuration
|
||||
*/
|
||||
public static validateBaseConfig(config: IBaseConfig): IValidationResult {
|
||||
return this.validate(config, this.baseConfigSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply defaults to a configuration object based on a schema
|
||||
|
Reference in New Issue
Block a user