Rust Implementation
This is the documentation of the Rust implementation of ivo.
Installation
How to use
ivo expects you to define your data model with structs that implement IvoInputStruct (required for input structs) and IvoStruct and this can be done via their respective derive macros as shown below.
use ;
use ;
type Timestamp = ;
IvoStruct
Deriving IvoStruct on User generates a struct called PartialUser together some helper methods for User and PartialUser.
-
User gets three helper methods with the following signatures:
-
PartialUser has the signature:
-
The
#[ivo(...)]attribute can be used to customize PartialStructs and their fields.// 👈 because it was provided above
IvoInputStruct
Deriving IvoInputStruct on UserInput automatically implements IvoStruct and generates two structs: PartialUserInput and UserInputErrors.
-
UserInputErrors is used to return errors from post-validators and grouped required resolvers and has the signature:
Fields
Below are links to examples on how to properly configure schema fields.
Constant Fields
Dependent Fields
Lax Fields
Required Fields
Virtual Fields
- Validators & re-validators
- With alias name
- With alias name same as dependent
- Required
- Ignore
- Ignore init
- Ignore update
Timestamps
Schema options
Ignore (Grouped)
- [With lax fields]: pay attention to the
should_properly_handle_grouped_ignore_rule&should_properly_handle_grouped_ignore_update_ruletest funtions here - [With virtual fields]: pay attention to the
should_properly_handle_grouped_ignore_rule,should_properly_handle_grouped_ignore_rule_with_alias&should_properly_handle_grouped_ignore_rule_with_alias_same_as_dependenttest funtions here
Ignore update (Grouped)
- [For the entire domain entity]: pay attention to the
should_respect_option_to_ignore_updates_with_empty_fields_arraytest funtion here - [With lax fields]: pay attention to the
should_properly_handle_grouped_ignore_update_ruletest funtion here - [With required fields]: pay attention to the
should_properly_handle_grouped_ignore_update_ruletest funtion here
Required (Grouped)
- [With lax fields]: pay attention to the
should_properly_handle_grouped_required_errorstest funtion here - [With virtual fields]: pay attention to the
should_properly_handle_grouped_required_errors,should_properly_handle_grouped_required_errors_with_alias&should_properly_handle_grouped_required_errors_with_alias_same_as_dependenttest funtions here
On Success (Grouped)
On Delete
Pay attention to the should_properly_trigger_on_delete_handlers & should_properly_trigger_all_on_delete_handlers test funtions here
Post-validate
- [With lax fields]: pay attention to the
should_respect_post_validation_config&should_respect_updated_values_returned_from_pre_validator_in_post_validation_configtest funtions here - [With required fields]: pay attention to the
should_respect_post_validation_config&should_respect_updated_values_returned_from_pre_validator_in_post_validation_configtest funtions here - [With virtual fields]: pay attention to the
should_respect_post_validation_config,should_respect_post_validation_config_with_alias,should_respect_post_validation_config_with_alias_same_as_dependent,should_respect_updated_values_returned_from_pre_validator_in_post_validation_config,should_respect_updated_values_returned_from_pre_validator_in_post_validation_config_with_alias&should_respect_updated_values_returned_from_pre_validator_in_post_validation_config_with_alias_same_as_dependenttest funtions here
Custom Context Options
Custom ErrorSanitizer
The default payload returned for unsuccessful operations has the following signature:
In Rust:
type DefaultFieldErrorMetadata = ;
type IvoErrorPayload<Metadata: Clone> = ;
In order to customize this payload, you just need to provide an implementation of the IvoErrorSanitizer trait that suits. Here is an example of how it can be done.