From 766e19af973a584e1cf446201e8b236c96f0b689 Mon Sep 17 00:00:00 2001 From: Marcin Olichwiruk <21108638+olichwiruk@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:10:15 +0100 Subject: [PATCH] feat: add validate function for semantic validation --- semantics/oca-bundle/src/state/validator.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/semantics/oca-bundle/src/state/validator.rs b/semantics/oca-bundle/src/state/validator.rs index 8c3a23d..b60ab5c 100644 --- a/semantics/oca-bundle/src/state/validator.rs +++ b/semantics/oca-bundle/src/state/validator.rs @@ -43,6 +43,19 @@ impl std::fmt::Display for Error { impl std::error::Error for Error {} +pub enum SemanticValidationStatus { + Valid, + Invalid(Vec), +} + +pub fn validate(oca_bundle: &OCABundle) -> Result { + 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, }