pub struct Validator { /* private fields */ }Expand description
Validates query elements against known schema and provides suggestions.
Implementations§
Source§impl Validator
impl Validator
Sourcepub fn add_table_name(&mut self, table: &str)
pub fn add_table_name(&mut self, table: &str)
Register a table name only (no column metadata).
Useful for views discovered from schema text where build-time parser does not infer projected columns. Table existence is validated, while column-level checks are skipped.
Sourcepub fn add_table_with_types(&mut self, table: &str, cols: &[(&str, &str)])
pub fn add_table_with_types(&mut self, table: &str, cols: &[(&str, &str)])
Register a table with column types (for future type validation).
§Arguments
table— Table name to register.cols— Slice of(column_name, column_type)pairs.
Sourcepub fn table_names(&self) -> &[String]
pub fn table_names(&self) -> &[String]
Get list of all table names (for autocomplete).
Sourcepub fn column_names(&self, table: &str) -> Option<&Vec<String>>
pub fn column_names(&self, table: &str) -> Option<&Vec<String>>
Get column names for a table (for autocomplete).
Sourcepub fn table_exists(&self, table: &str) -> bool
pub fn table_exists(&self, table: &str) -> bool
Check if a table exists.
Sourcepub fn validate_table(&self, table: &str) -> Result<(), ValidationError>
pub fn validate_table(&self, table: &str) -> Result<(), ValidationError>
Check if a table exists. If not, returns structured error with suggestion.
Sourcepub fn validate_column(
&self,
table: &str,
column: &str,
) -> Result<(), ValidationError>
pub fn validate_column( &self, table: &str, column: &str, ) -> Result<(), ValidationError>
Check if a column exists in a table. If not, returns a structured error.
§Arguments
table— Table to look up.column— Column name to validate.
Sourcepub fn get_column_type(&self, table: &str, column: &str) -> Option<&String>
pub fn get_column_type(&self, table: &str, column: &str) -> Option<&String>
Get column type for a table.column
Sourcepub fn validate_value_type(
&self,
table: &str,
column: &str,
value: &Value,
) -> Result<(), ValidationError>
pub fn validate_value_type( &self, table: &str, column: &str, value: &Value, ) -> Result<(), ValidationError>
Validate that a Value’s type matches the expected column type. Returns Ok(()) if compatible, Err with TypeMismatch if not.
Sourcepub fn validate_command(&self, cmd: &Qail) -> ValidationResult
pub fn validate_command(&self, cmd: &Qail) -> ValidationResult
Validate an entire Qail against the schema.