Use is_amount clap validator (#7400)
* Fix up is_amount to handle floats for SOL; expand amount_of test * Use required_lamports_from and is_amount across CLI * Remove obsolete test (now handled by clap)
This commit is contained in:
@ -120,8 +120,12 @@ pub fn is_valid_percentage(percentage: String) -> Result<(), String> {
|
||||
}
|
||||
|
||||
pub fn is_amount(amount: String) -> Result<(), String> {
|
||||
amount
|
||||
.parse::<u64>()
|
||||
.map(|_| ())
|
||||
.map_err(|e| format!("{:?}", e))
|
||||
if amount.parse::<u64>().is_ok() || amount.parse::<f64>().is_ok() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!(
|
||||
"Unable to parse input amount as integer or float, provided: {}",
|
||||
amount
|
||||
))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user