30
crates/cuddle/src/schema_validator.rs
Normal file
30
crates/cuddle/src/schema_validator.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
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,
|
||||
)?)),
|
||||
RawPlanSchema::JsonSchema { jsonschema } => todo!("jsonschema not implemented yet"),
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user