Skip to main content

xrust/validators/
mod.rs

1pub mod dtd;
2
3use crate::item::{Node, NodeType};
4use crate::validators::dtd::validate_dtd;
5
6#[derive(Clone)]
7pub enum Schema {
8    DTD, //Will add the rest as they become available.
9}
10
11#[derive(Debug)]
12pub enum ValidationError {
13    DocumentError(String),
14    SchemaError(String),
15}
16
17pub(crate) fn validate(doc: &impl Node, schema: Schema) -> Result<(), ValidationError> {
18    match doc.node_type() {
19        NodeType::Document => match schema {
20            Schema::DTD => validate_dtd(doc.clone()),
21        },
22        _ => Err(ValidationError::DocumentError(
23            "Node provided was not a document".to_string(),
24        )),
25    }
26}