pub struct DocumentValidator { /* private fields */ }validation only.Expand description
Validates create documents for one resource.
Implementations§
Source§impl DocumentValidator
impl DocumentValidator
Sourcepub fn for_create(schema: &ResourceSchema) -> Result<Self, BuildError>
Available on crate feature domain only.
pub fn for_create(schema: &ResourceSchema) -> Result<Self, BuildError>
domain only.Derive a create-body validator from an ash-domain schema.
The ash-domain shortcut for
DocumentValidator::builder:
attribute types come from ResourceSchema::to_json_schema, and the
members JSON:API carries elsewhere are hidden — the primary key, which
belongs in the envelope, and every relationship’s foreign key, which
belongs in linkage.
Note what hiding does and does not do. hide
removes a property from the generated schema, so the member is no
longer described; it does not set additionalProperties: false, so
it is not forbidden either. Sending a hidden member is therefore not
an error — it is ignored. What keeps it from taking effect is the
reading side: Mounted’s document reader skips the primary key, so a
client cannot choose a row’s id by sending attributes.id.
Relationships are optional in the document: whether one is required is a domain policy, not a question about the document’s shape.
Source§impl DocumentValidator
impl DocumentValidator
Sourcepub fn builder<S: ResourceDef>(schema: &S) -> ValidatorBuilder<'_, S>
pub fn builder<S: ResourceDef>(schema: &S) -> ValidatorBuilder<'_, S>
Start building a validator for schema.