Rust

The registry of attribute formats: named validators an attribute's format selects, for one attribute type (an email format of string attributes, an enum of string, a range of integer).

Rust
use std::sync::Arc;
use utopia_database::validator::structure::formats;
use utopia_validators::Text;

formats::add("short", Arc::new(|_attribute| Box::new(Text::new(5))), "string");
assert!(formats::has("short", "string"));
assert!(!formats::has("short", "integer"));
formats::remove("short");

Contents

use utopia_database::validator::structure::formats::Format;
Rust
pub struct Format

A registered format.

use utopia_database::validator::structure::formats::add;
Rust
pub fn add(name: &str, factory: Factory, kind: &str)

Registers (or replaces) a format.

use utopia_database::validator::structure::formats::all;
Rust
pub fn all() -> Vec<Format>

Every format, in registration order.

use utopia_database::validator::structure::formats::get;
Rust
pub fn get(name: &str, kind: &str) -> Result<Format>

Fails (crate::Kind::Database) with Format "..." not available for attribute type "..." or Unknown format validator "...".

use utopia_database::validator::structure::formats::has;
Rust
pub fn has(name: &str, kind: &str) -> bool

Undocumented.

use utopia_database::validator::structure::formats::remove;
Rust
pub fn remove(name: &str)

Undocumented.

Rust
pub type Factory = Arc<dyn Fn(&Document) -> Box<dyn utopia_validators::Validator> + Send + Sync>

Builds a format's validator for an attribute (its definition: size, formatOptions, ...).