-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
ValidationError
's string representation more informative
* Added a source_type and message field to ValidationError. - ValidationError should have more detail. - ValidationError::message should maybe have a String so people can use format! to generate the messages. * Forgot the changes in lib. * Made the ValidationError message for Ensure closures lowercase and remove the period. * Debug nad Display impls for ValidationError use the message field. * `ValidationError::message` retyped from `&str` to `String`. - String allows for error messages constructed using format! and such macros. * ConstructionError includes the input value in the error mesasge. - The message field is removed as there is no need for custom error messages yet. - The type alias is passed given to the Error so it can print it. * Restored the assert_matches in the tests. * Made the ConstructionError::guarded_type_name a &'static str. * Renamed ConstructionError back to ValidationError. - There was a plan to have two errors, one for Construction and another for Mutation. This is not going ahead due to it requiring major arch changes. * Fixed a sloppy rename. * Minor fixes * Add comment about test `test_deps` * Check if `define!` works with non-clonable types * Removed value from ValidationError. - The value would force the users type to implement `Clone`. * Reinstated value to `ValidationError` but as a `String`. - This allows the error to store a value without a generic `T: Clone + Debug` * Remove junk file * Fix comment Co-authored-by: Alex Ryapolov <ryapolov@pm.me>
- Loading branch information
Showing
11 changed files
with
83 additions
and
34 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
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,11 @@ | ||
#[derive(Debug)] | ||
struct User { | ||
name: String, | ||
} | ||
|
||
prae::define! { | ||
ValidUser: User | ||
ensure |u| !u.name.is_empty() | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod adjust_ensure; | ||
mod adjust_validate; | ||
mod ensure; | ||
mod validate; | ||
mod non_clone; | ||
mod validate; |
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