#[derive(Validate)]
{
// Attributes available to this derive:
#[validate]
}
Expand description
The main procedural macro function for #[derive(Validate)].
This function is invoked by the Rust compiler when #[derive(Validate)]
is encountered. It takes the TokenStream of the struct definition as input
and returns a TokenStream containing the generated impl Validate for ... block.
§Generated Traits
impl Validate for T- Simple validation without contextimpl ValidateArgs<'_> for T- Validation with optional context
§Steps
- Parses the input
TokenStreaminto asyn::DeriveInput - Uses
ValidationData::from_derive_input(powered bydarling) to parse attributes into theValidationDatastruct - Extracts necessary information like struct identifier, generics, and parsed field data
- Generates
usestatements for validator traits - Generates code for struct-level schema validations
- Iterates over fields, generating field-specific validation logic
- Assembles the final
impl ValidateArgs for ...and optionallyimpl Validate for ...blocks