30 lines
654 B
Rust
30 lines
654 B
Rust
use nickel::NickelSchemaValidator;
|
|
|
|
use crate::{
|
|
plan::{RawPlan, RawPlanSchema},
|
|
project::RawProject,
|
|
};
|
|
|
|
mod nickel;
|
|
|
|
pub struct SchemaValidator {}
|
|
|
|
impl SchemaValidator {
|
|
pub fn new() -> Self {
|
|
Self {}
|
|
}
|
|
|
|
pub fn validate(&self, plan: &RawPlan, project: &RawProject) -> anyhow::Result<Option<()>> {
|
|
let schema = match &plan.config.plan.schema {
|
|
Some(schema) => schema,
|
|
None => return Ok(None),
|
|
};
|
|
|
|
match schema {
|
|
RawPlanSchema::Nickel { nickel } => Ok(Some(NickelSchemaValidator::validate(
|
|
plan, project, nickel,
|
|
)?)),
|
|
}
|
|
}
|
|
}
|