Skip to content

Commit

Permalink
fix: Improve validation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpinder committed Dec 14, 2024
1 parent 4103184 commit fe18acd
Show file tree
Hide file tree
Showing 69 changed files with 2,505 additions and 346 deletions.
349 changes: 171 additions & 178 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions src/commands/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,21 @@ impl BlueBuildCommand for ValidateCommand {
impl ValidateCommand {
async fn setup_validators(&mut self) -> Result<(), Report> {
let (rv, sv, mv, mslv) = tokio::try_join!(
SchemaValidator::builder().url(RECIPE_V1_SCHEMA_URL).build(),
SchemaValidator::builder().url(STAGE_V1_SCHEMA_URL).build(),
SchemaValidator::builder().url(MODULE_V1_SCHEMA_URL).build(),
SchemaValidator::builder()
.url(RECIPE_V1_SCHEMA_URL)
.all_errors(self.all_errors)
.build(),
SchemaValidator::builder()
.url(STAGE_V1_SCHEMA_URL)
.all_errors(self.all_errors)
.build(),
SchemaValidator::builder()
.url(MODULE_V1_SCHEMA_URL)
.all_errors(self.all_errors)
.build(),
SchemaValidator::builder()
.url(MODULE_STAGE_LIST_V1_SCHEMA_URL)
.all_errors(self.all_errors)
.build(),
)?;
self.recipe_validator = Some(rv);
Expand Down Expand Up @@ -153,7 +163,7 @@ impl ValidateCommand {
.module_stage_list_validator
.as_ref()
.unwrap()
.process_validation(path, file_str.clone(), self.all_errors)
.process_validation(path, file_str.clone())
{
Err(e) => return vec![e],
Ok(e) => e,
Expand Down Expand Up @@ -200,7 +210,7 @@ impl ValidateCommand {
} else {
debug!("{path_display} is a single file file");
single_validator
.process_validation(path, file_str, self.all_errors)
.process_validation(path, file_str)
.map_or_else(|e| vec![e], |e| e.map_or_else(Vec::new, |e| vec![e]))
}
}
Expand All @@ -221,7 +231,7 @@ impl ValidateCommand {

let schema_validator = self.recipe_validator.as_ref().unwrap();
let err = schema_validator
.process_validation(&self.recipe, recipe_str.clone(), self.all_errors)
.process_validation(&self.recipe, recipe_str.clone())
.map_err(err_vec)?;

if let Some(err) = err {
Expand Down
Loading

0 comments on commit fe18acd

Please sign in to comment.