-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] #1734: Validate Name
to exclude whitespaces
#1743
Conversation
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## iroha2-dev #1743 +/- ##
==============================================
+ Coverage 77.18% 77.43% +0.25%
==============================================
Files 132 132
Lines 20412 20479 +67
==============================================
+ Hits 15754 15858 +104
+ Misses 4658 4621 -37
Continue to review full report at Codecov.
|
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
@@ -245,20 +245,20 @@ mod tests { | |||
let mut metadata = Metadata::new(); | |||
let limits = Limits::new(10, 15); | |||
metadata | |||
.insert_with_limits("0".to_owned(), Metadata::new().into(), limits) | |||
.insert_with_limits(Name::test("0"), Metadata::new().into(), limits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the function that creates a new name called test
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it instantly constructs Name
assuming the input is valid.
In contrast, Name::new
gracefully constructs and returns Result<Self>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unchecked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name::test
includes parsing and unwrapping so if any whitespaces it panics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend here:
new
->parse
because this is essentially wrapper forString::parse
test
->new
/parse_unwrap
because test
is very ambiguous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new
intends the default constructor.
test
would be renamed to unchecked
, instant
, or succeed
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
* Fix JSONs according to #1743 `Domain` struct change Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com> * Fix `status` term to `telemetry` according to #1725 Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com> * Fix `status_address` Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
Description of the Change
Name
of domain, account, asset, metadata key, and permission token.Domain
byId
instead ofName
Now
Id::new
s returnResult<Self>
, while previous implementations are left asId::test
s for usabilityIssue
Close #1734
Benefits
Type level guarantee of no whitespaces in
Name
Possible Drawbacks
There might be a better error handling for
Name
validation