Skip to content

Commit

Permalink
validate: refactor currency_format_checker
Browse files Browse the repository at this point in the history
- use faster is_empty instead of len() > 0
- allow empty currency symbol
  • Loading branch information
jqnatividad committed Sep 22, 2024
1 parent f45c3c0 commit a020a99
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cmd/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ struct RFC4180Struct {
}

#[inline]
/// Checks if a string is a valid currency
/// Checks if a given string represents a valid currency format.
fn currency_format_checker(s: &str) -> bool {
Currency::from_str(s).map_or(false, |c| {
if c.symbol().len() > 0 {
qsv_currency::Currency::is_iso_currency(&c)
if c.symbol().is_empty() {
true // allow empty currency symbol
} else {
false
qsv_currency::Currency::is_iso_currency(&c)
}
})
}
Expand Down

0 comments on commit a020a99

Please sign in to comment.