-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [#978] add semantic validation for configration
The section [core.provate_mode] can be inlcuded in the configration TOML file only if the tracker is running in private mode (`private = true`). This commits adds that validation and makes it possible to add more semantic validations in the future. Semantic validations are validations that depend on more than one value. Like the one added, it could be any other incompatible combination.
- Loading branch information
1 parent
e8e935c
commit 258f732
Showing
5 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//! Trait to validate semantic errors. | ||
//! | ||
//! Errors could involve more than one configuration option. Some configuration | ||
//! combinations can be incompatible. | ||
use thiserror::Error; | ||
|
||
/// Errors that can occur validating the configuration. | ||
#[derive(Error, Debug)] | ||
pub enum SemanticValidationError { | ||
#[error("Private mode section in configuration can only be included when the tracker is running in private mode.")] | ||
UselessPrivateModeSection, | ||
} | ||
|
||
pub trait Validator { | ||
/// # Errors | ||
/// | ||
/// Will return an error if the configuration is invalid. | ||
fn validate(&self) -> Result<(), SemanticValidationError>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters