Skip to content

Commit

Permalink
feat: add validate function for semantic validation
Browse files Browse the repository at this point in the history
  • Loading branch information
olichwiruk committed Dec 6, 2024
1 parent ef7e60d commit 766e19a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions semantics/oca-bundle/src/state/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ impl std::fmt::Display for Error {

impl std::error::Error for Error {}

pub enum SemanticValidationStatus {
Valid,
Invalid(Vec<Error>),
}

pub fn validate(oca_bundle: &OCABundle) -> Result<SemanticValidationStatus, String> {
let validator = Validator::new();
match validator.validate(oca_bundle) {
Ok(_) => Ok(SemanticValidationStatus::Valid),
Err(errors) => Ok(SemanticValidationStatus::Invalid(errors)),
}
}

pub struct Validator {
enforced_translations: Vec<Language>,
}
Expand Down

0 comments on commit 766e19a

Please sign in to comment.