#[migration_validator]Expand description
A procedural macro that lets you set up the migration validator. Right now, you
can validate only the migration context, but using the set_context_validator for
the whole context validation, and set_context_parameter_validator for per-parameter
validation. For more information, check out these functions’ doc comments.
Example usage:
ⓘ
#[migration_validator]
pub fn migration_validator(mv: &mut picodata_plugin::plugin::interface::MigrationValidator) {
mv.set_context_validator(|ctx| {
if ctx.len() >= 3 {
Err("this context is too long, man".into())
} else {
Ok(())
}
});
mv.set_context_parameter_validator(|k, v| match k.as_str() {
"always_ok_parameter" => Ok(()),
"always_bad_parameter" => Err("don't use this parameter, please".into()),
"short_parameter" => {
if v.len() > 15 {
Err("this parameter can't be that long!".into())
} else {
Ok(())
}
}
_ => Ok(()),
});
}