Updated DecryptedAccount::validate to use an all method of the iterators
This commit is contained in:
		@@ -4,6 +4,8 @@ use cryptography::prelude::*;
 | 
			
		||||
use entity::prelude::*;
 | 
			
		||||
use serde::{Deserialize, Serialize};
 | 
			
		||||
 | 
			
		||||
use crate::utils::validate_field;
 | 
			
		||||
 | 
			
		||||
#[derive(Serialize, Deserialize)]
 | 
			
		||||
pub struct DecryptedAccount {
 | 
			
		||||
    pub name: String,
 | 
			
		||||
@@ -43,15 +45,9 @@ impl DecryptedAccount {
 | 
			
		||||
    /// Returns true if the account's fields are valid
 | 
			
		||||
    #[inline]
 | 
			
		||||
    pub fn validate(&self) -> bool {
 | 
			
		||||
        for string in [&self.name, &self.login, &self.password] {
 | 
			
		||||
            let is_invalid = string
 | 
			
		||||
                .chars()
 | 
			
		||||
                .any(|char| char == '`' || char == '\\' || char == '\n');
 | 
			
		||||
            if is_invalid {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        true
 | 
			
		||||
        [&self.name, &self.login, &self.password]
 | 
			
		||||
            .into_iter()
 | 
			
		||||
            .all(|field| validate_field(field))
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user