versa_semval 0.7.2

Cross-platform module for semantic validation of Versa data
Documentation
use std::fmt::{Display, Formatter};

#[cfg_attr(feature = "nodejs", napi(string_enum))]
#[derive(Debug)]
pub enum SemanticValidationError {
  JsonObjectError,
}

impl Display for SemanticValidationError {
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
    match self {
      SemanticValidationError::JsonObjectError => write!(f, "json_object_error"),
    }
  }
}

#[cfg_attr(feature = "nodejs", napi(object))]
#[derive(Clone, Debug)]
pub struct Violation {
  pub description: String,
  pub details: Option<String>,
  pub rule: String,
}

#[derive(Clone, Debug)]
pub struct ViolationDetails {
  pub details: Option<String>,
}

#[cfg_attr(feature = "nodejs", napi(object))]
#[derive(Clone, Debug)]
pub struct SemanticValidationOutput {
  pub error: Option<String>,
  pub violations: Vec<Violation>,
}