src/api2/types.rs: define and use PASSWORD_REGEX

This commit is contained in:
Dietmar Maurer 2020-01-14 11:22:42 +01:00
parent ff620a3d1a
commit da4a15a351
2 changed files with 4 additions and 2 deletions

View File

@ -32,6 +32,8 @@ const_regex!{
pub SHA256_HEX_REGEX = r"^[a-f0-9]{64}$"; // fixme: define in common_regex ? pub SHA256_HEX_REGEX = r"^[a-f0-9]{64}$"; // fixme: define in common_regex ?
pub SYSTEMD_DATETIME_REGEX = r"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$"; // fixme: define in common_regex ? pub SYSTEMD_DATETIME_REGEX = r"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$"; // fixme: define in common_regex ?
pub PASSWORD_REGEX = r"^[[:^cntrl:]]*$"; // everything but control characters
/// Regex for safe identifiers. /// Regex for safe identifiers.
/// ///
/// This /// This

View File

@ -14,9 +14,9 @@ lazy_static! {
static ref CONFIG: SectionConfig = init(); static ref CONFIG: SectionConfig = init();
} }
// fixme: define better schemas
pub const REMOTE_PASSWORD_SCHEMA: Schema = StringSchema::new("Password or auth token for remote host.") pub const REMOTE_PASSWORD_SCHEMA: Schema = StringSchema::new("Password or auth token for remote host.")
.format(&PASSWORD_REGEX)
.min_length(1)
.max_length(1024) .max_length(1024)
.schema(); .schema();