fix: Reject empty string field value
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
parent
6e5e3c093c
commit
6f5ca5f452
2 changed files with 25 additions and 0 deletions
|
@ -92,6 +92,29 @@ impl LprsCommand for Add {
|
|||
)));
|
||||
}
|
||||
}
|
||||
if self
|
||||
.password
|
||||
.as_ref()
|
||||
.is_some_and(|p| p.as_ref().is_some_and(|p| p.is_empty()))
|
||||
|| self.vault_info.name.is_empty()
|
||||
|| self
|
||||
.vault_info
|
||||
.username
|
||||
.as_ref()
|
||||
.is_some_and(|u| u.is_empty())
|
||||
|| self
|
||||
.vault_info
|
||||
.service
|
||||
.as_ref()
|
||||
.is_some_and(|s| s.is_empty())
|
||||
|| self.vault_info.note.as_ref().is_some_and(|n| n.is_empty())
|
||||
|| self
|
||||
.custom_fields
|
||||
.iter()
|
||||
.any(|(k, v)| k.is_empty() || v.is_empty())
|
||||
{
|
||||
return Err(LprsError::EmptyValue);
|
||||
}
|
||||
if self
|
||||
.custom_fields
|
||||
.iter()
|
||||
|
|
|
@ -44,6 +44,8 @@ pub enum Error {
|
|||
custom fields {0}"
|
||||
)]
|
||||
ReservedPrefix(&'static str),
|
||||
#[error("Invalid Field Value: Field value cannot be empty")]
|
||||
EmptyValue,
|
||||
#[error("Base32 Error: {0}")]
|
||||
Base32(String),
|
||||
#[error("{0}")]
|
||||
|
|
Loading…
Reference in a new issue