fix: Reject empty string field value #63

Merged
awiteb merged 1 commit from awiteb/fix-52 into master 2024-07-24 10:08:57 +02:00 AGit
2 changed files with 25 additions and 0 deletions
Showing only changes of commit 6f5ca5f452 - Show all commits

View file

@ -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 if self
.custom_fields .custom_fields
.iter() .iter()

View file

@ -44,6 +44,8 @@ pub enum Error {
custom fields {0}" custom fields {0}"
)] )]
ReservedPrefix(&'static str), ReservedPrefix(&'static str),
#[error("Invalid Field Value: Field value cannot be empty")]
EmptyValue,
#[error("Base32 Error: {0}")] #[error("Base32 Error: {0}")]
Base32(String), Base32(String),
#[error("{0}")] #[error("{0}")]