src/api2/types.rs: define SINGLE_LINE_COMMENT_SCHEMA

This commit is contained in:
Dietmar Maurer
2020-01-13 12:02:13 +01:00
parent 167971ed49
commit 454c13edce
5 changed files with 13 additions and 12 deletions

View File

@ -29,6 +29,8 @@ const_regex!{
/// names this way. This is not only useful for filenames, but for
/// any identifier command line tools work with.
pub PROXMOX_SAFE_ID_REGEX = r"^[A-Za-z0-9_][A-Za-z0-9._\-]*";
pub SINGLE_LINE_COMMENT_REGEX = r"^[[:^cntrl:]]*$";
}
pub const SYSTEMD_DATETIME_FORMAT: ApiStringFormat =
@ -43,6 +45,10 @@ pub const PVE_CONFIG_DIGEST_FORMAT: ApiStringFormat =
pub const PROXMOX_SAFE_ID_FORMAT: ApiStringFormat =
ApiStringFormat::Pattern(&PROXMOX_SAFE_ID_REGEX);
pub const SINGLE_LINE_COMMENT_FORMAT: ApiStringFormat =
ApiStringFormat::Pattern(&SINGLE_LINE_COMMENT_REGEX);
pub const PVE_CONFIG_DIGEST_SCHEMA: Schema = StringSchema::new(r#"\
Prevent changes if current configuration file has different SHA256 digest.
This can be used to prevent concurrent modifications.
@ -123,6 +129,9 @@ pub const REMOTE_ID_SCHEMA: Schema = StringSchema::new("Remote ID.")
.max_length(32)
.schema();
pub const SINGLE_LINE_COMMENT_SCHEMA: Schema = StringSchema::new("Comment (single line).")
.format(&SINGLE_LINE_COMMENT_FORMAT)
.schema();
// Complex type definitions