Documentation / Runique Admin / Boot validation
Boot validation
No admin file generation anymore. Instead, AdminStaging::validate() checks the whole config before routes are mounted. An error stops startup with a clear message.
When it runs
.with_admin(admin::config)builds the stagingbuild()callsstaging.validate()- On
Ok, CRUD routes mount underprefix + path
You can replay the same checks in a test:
#[test]
fn every_registered_model_passes_the_boot_checks() {
let staging = super::config(AdminStaging::new().enable());
if let Err(e) = staging.validate() {
panic!("{e}");
}
}
What is checked
Per model
List
linksandsortableonly name columns ofdisplay;search_helpwithout a search (search([])) is refused;- a grouped action doesn't target the primary key, its value fits the column, and one column doesn't get the same value twice.
Form
- each field of
fieldsexists in the model's form (ModelMeta::Form) and can hold the column's type; - fields named elsewhere (labels, read-only…) are in
fields; - a secret column required on create (NOT NULL, no default) is refused: the admin could never fill it, give it a default.
Both
- a secret column (
password…) appears in no list: display, search, filter, sort, form, action; - a grouped action targets a column the form writes on edit (in
fields, neitherreadonlynorcreate_only); - a grouped action never targets the owner column: a transfer is its own operation;
- on the accounts: no grouped action on the ranks or on
is_active, and no rank flag infields.
Site level
- a model registered twice is refused;
- the accounts admin is replaced only through
accounts_users, with theeihwaz_userstable (its key and protections); - the groups are served by the framework: registering them is refused.
Staging level
- the admin path isn't empty;
- admin routes declared in
urlpatterns!while the admin is disabled: refused; - each declared admin route targets a registered model, has an absolute path (exactly one
{id}segment, and nothing else, to replace the detail), overlaps neither a public route nor the admin's namespace, is declared once (path and name), and a view is replaced only once.
Elsewhere at boot
- the template overrides (see Template override);
- in production,
with_public_urlis required when the admin is enabled; - the rights targeting an unregistered model (the groups' as well as the admins' grids) are permanently deleted from the database (only once the project registered at least one of its models).
Defaults
- without
display: every column but the secret ones; on the accounts, onlyusername,email,is_active; - without
.form(): every field of the model's form (ModelMeta::Form).
At runtime, each column list is then cut to what the user's rights let them see or write.
Relevant files
| File | Role |
|---|---|
src/admin.rs | Your config (maintain this) |
runique/src/admin/builder/ | Builder + validation |
runique/src/app/staging/admin_staging.rs | Staging + validate() |
Nothing is written under src/admins/: that folder is gone.