Skip to content

Commit

Permalink
refactor: rename vars
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-tekuri committed Apr 10, 2024
1 parent 75b242a commit 91f58ae
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,24 +673,24 @@ impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {

// allOf --
if !s.all_of.is_empty() {
let mut allof_errors = vec![];
let mut errors = vec![];
for sch in &s.all_of {
if let Err(e) = self.validate_self(*sch) {
allof_errors.push(e);
errors.push(e);
if self.bool_result {
break;
}
}
}
if !allof_errors.is_empty() {
self.add_errors(allof_errors, kind!(AllOf));
if !errors.is_empty() {
self.add_errors(errors, kind!(AllOf));
}
}

// anyOf --
if !s.any_of.is_empty() {
let mut matched = false;
let mut anyof_errors = vec![];
let mut errors = vec![];
for sch in &s.any_of {
match self.validate_self(*sch) {
Ok(_) => {
Expand All @@ -700,21 +700,22 @@ impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
break;
}
}
Err(e) => anyof_errors.push(e),
Err(e) => errors.push(e),
}
}
if !matched {
self.add_errors(anyof_errors, kind!(AnyOf));
self.add_errors(errors, kind!(AnyOf));
}
}

// oneOf --
if !s.one_of.is_empty() {
let (mut matched, mut oneof_errors) = (None, vec![]);
let mut matched = None;
let mut errors = vec![];
for (i, sch) in s.one_of.iter().enumerate() {
if let Err(e) = self._validate_self(*sch, None, matched.is_some()) {
if matched.is_none() {
oneof_errors.push(e);
errors.push(e);
}
} else {
match matched {
Expand All @@ -727,7 +728,7 @@ impl<'v, 's, 'd, 'e> Validator<'v, 's, 'd, 'e> {
}
}
if matched.is_none() {
self.add_errors(oneof_errors, ErrorKind::OneOf(None));
self.add_errors(errors, ErrorKind::OneOf(None));
}
}

Expand Down

0 comments on commit 91f58ae

Please sign in to comment.