Skip to content

Commit

Permalink
add offset
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Dec 26, 2024
1 parent f7cdce5 commit 9cdb1f2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/markdown/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ fn get_position(content: &str, line_offsets: &[usize], start: usize, end: usize)
start: start_col,
end: end_col,
},
offset: PositionRange {
start: start,
end: end,
},
}
}

Expand Down
1 change: 1 addition & 0 deletions src/markdown/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use pyo3::prelude::*;
pub struct Position {
pub line: usize,
pub column: PositionRange,
pub offset: PositionRange,
}

impl PartialOrd for Position {
Expand Down
19 changes: 19 additions & 0 deletions src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,25 @@ impl Validator {
) {
let attribute_positions = extract_attribute_positions(object);

if dtype.is_empty() {
self.add_error(ValidationError {
message: format!(
"Property '{}' has no type defined. Either define a type or use a base type.",
attribute.name
),
object: Some(object.name.clone()),
attribute: Some(attribute.name.clone()),
location: "Global".into(),
error_type: ErrorType::TypeError,
positions: attribute_positions
.get(&attribute.name)
.cloned()
.unwrap_or_default(),
});

return;
}

if !types.contains(&dtype) && !BASIC_TYPES.contains(&dtype) {
self.add_error(ValidationError {
message: format!(
Expand Down

0 comments on commit 9cdb1f2

Please sign in to comment.