MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / validate_literal

Function validate_literal

graphlite/src/ast/validator.rs:2020–2051  ·  view source on GitHub ↗

Validate literals

(literal: &Literal, errors: &mut Vec<ValidationError>)

Source from the content-addressed store, hash-verified

2018
2019/// Validate literals
2020fn validate_literal(literal: &Literal, errors: &mut Vec<ValidationError>) {
2021 match literal {
2022 Literal::String(s) => {
2023 if s.is_empty() {
2024 errors.push(ValidationError {
2025 message: "String literal cannot be empty".to_string(),
2026 location: None,
2027 error_type: ValidationErrorType::Syntax,
2028 });
2029 }
2030 }
2031 Literal::Vector(v) => {
2032 if v.is_empty() {
2033 errors.push(ValidationError {
2034 message: "Vector literal cannot be empty".to_string(),
2035 location: None,
2036 error_type: ValidationErrorType::Syntax,
2037 });
2038 }
2039 }
2040 Literal::DateTime(dt) => {
2041 validate_datetime_format(dt, errors);
2042 }
2043 Literal::Duration(dur) => {
2044 validate_duration_format(dur, errors);
2045 }
2046 Literal::TimeWindow(tw) => {
2047 validate_timewindow_format(tw, errors);
2048 }
2049 _ => {} // Other literals are fine
2050 }
2051}
2052
2053/// Validate datetime format
2054fn validate_datetime_format(dt: &str, errors: &mut Vec<ValidationError>) {

Callers 1

validate_expressionFunction · 0.85

Calls 4

validate_datetime_formatFunction · 0.85
validate_duration_formatFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected