pub struct TableValidator;Expand description
Table validator
Implementations§
Source§impl TableValidator
impl TableValidator
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new table validator
§Example
use data_modelling_core::validation::tables::TableValidator;
let validator = TableValidator::new();Sourcepub fn detect_naming_conflicts(
&self,
existing_tables: &[Table],
new_tables: &[Table],
) -> Vec<NamingConflict>
pub fn detect_naming_conflicts( &self, existing_tables: &[Table], new_tables: &[Table], ) -> Vec<NamingConflict>
Detect naming conflicts between new tables and existing tables
The logic checks for conflicts using unique keys: (database_type, name, catalog_name, schema_name)
§Arguments
existing_tables- Tables that already existnew_tables- New tables to check for conflicts
§Returns
A vector of NamingConflict structs for each conflict found.
§Example
use data_modelling_core::validation::tables::TableValidator;
use data_modelling_core::models::{Table, Column};
let validator = TableValidator::new();
let existing = vec![Table::new("users".to_string(), vec![])];
let new_tables = vec![Table::new("users".to_string(), vec![])];
let conflicts = validator.detect_naming_conflicts(&existing, &new_tables);
assert_eq!(conflicts.len(), 1);Sourcepub fn validate_pattern_exclusivity(
&self,
table: &Table,
) -> Result<(), PatternViolation>
pub fn validate_pattern_exclusivity( &self, table: &Table, ) -> Result<(), PatternViolation>
Validate pattern exclusivity (SCD pattern and Data Vault classification are mutually exclusive)
§Arguments
table- The table to validate
§Returns
Ok(()) if valid, Err(PatternViolation) if both SCD pattern and Data Vault classification are set.
§Example
use data_modelling_core::validation::tables::TableValidator;
use data_modelling_core::models::{Table, Column};
use data_modelling_core::models::enums::{SCDPattern, DataVaultClassification};
let validator = TableValidator::new();
let mut table = Table::new("test".to_string(), vec![]);
table.scd_pattern = Some(SCDPattern::Type2);
table.data_vault_classification = Some(DataVaultClassification::Hub);
let result = validator.validate_pattern_exclusivity(&table);
assert!(result.is_err());Trait Implementations§
Source§impl Default for TableValidator
impl Default for TableValidator
Source§fn default() -> TableValidator
fn default() -> TableValidator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TableValidator
impl RefUnwindSafe for TableValidator
impl Send for TableValidator
impl Sync for TableValidator
impl Unpin for TableValidator
impl UnwindSafe for TableValidator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more