47 lines
1.1 KiB
Rust
47 lines
1.1 KiB
Rust
//! Configuration validation with JSON Schema.
|
|
|
|
use crate::{ConfigResult, ConfigValue};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// Validation rule for configuration values.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct ValidationRule {
|
|
pub key_pattern: String,
|
|
pub required: bool,
|
|
pub value_type: Option<String>,
|
|
pub min_value: Option<f64>,
|
|
pub max_value: Option<f64>,
|
|
pub allowed_values: Option<Vec<String>>,
|
|
}
|
|
|
|
/// Validation schema for configuration.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct ValidationSchema {
|
|
pub rules: Vec<ValidationRule>,
|
|
}
|
|
|
|
/// Configuration validator.
|
|
#[derive(Debug)]
|
|
pub struct ConfigValidator {
|
|
_schema: ValidationSchema,
|
|
}
|
|
|
|
impl ConfigValidator {
|
|
pub fn new() -> Self {
|
|
Self {
|
|
_schema: ValidationSchema { rules: Vec::new() },
|
|
}
|
|
}
|
|
|
|
pub async fn validate_value(&self, _key: &str, _value: &ConfigValue) -> ConfigResult<()> {
|
|
// Placeholder implementation
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl Default for ConfigValidator {
|
|
fn default() -> Self {
|
|
Self::new()
|
|
}
|
|
}
|