Skip to content
Back to skills

Validation And Input

ASecurity

Validates request bodies, query strings, forms, uploads, and custom rules in Laravel for Rust. Use when defining input or query structs, validating requests, handling PATCH updates, or writing custom validation rules.

  • 8 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
developmentrustapi

Works with

  • api

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add danielhe4rt/overthinking-canvas-rs --skill validation-and-input --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Validation And Input?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Validation And Input
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/danielhe4rt-validation-and-input/badge)](https://www.skillsdirectory.com/skills/danielhe4rt-validation-and-input)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: validation-and-input
description: Validates request bodies, query strings, forms, uploads, and custom rules in Laravel for Rust. Use when defining input or query structs, validating requests, handling PATCH updates, or writing custom validation rules.
---

# Validation & Typed Request Input

Consult `<docs>/validation.md` and `<docs>/requests.md` (locate via `.agents/skills/writing-laravel-rust-apps/scripts/docs-path.sh`) for the full rule catalog, nested/list validation, custom messages, and custom rule APIs.

## Core Rules & Footguns

- Never use Axum's `Form<T>`, `Json<T>`, or `Query<T>` extractors—they skip Laravel's error handling and respond with plain text. Always use Laravel's `Valid<T>` (`#[laravel::input]`) for bodies and `Query<T>` (`#[laravel::query]`) for query strings.
- Body input and query strings are strictly separated. `Valid<T>` and `request.parse()` read only the request body; `Query<T>` and `request.query()` read only the query string.
- `Valid<T>` consumes the request body and must be the handler's last argument. If your handler needs both validated input and `Request`, take `ValidRequest<T>` as the last argument instead of both.
- Every `#[laravel::input]` struct validated from a request must declare who may submit it via `#[validate(anyone)]`, `#[validate(authenticated)]`, or a `ValidatesRequest::authorize` hook—omitting it fails to compile.
- Use parenthesized rule arguments in `#[validate(...)]` (e.g., `max_length(255)`, `min_value(1)`, `unique(Post::title)`, `exists(Post::id)`). You do not need type rules like `string` or `integer` because the Rust field types enforce them.
- Attach `fills = Model` (`#[laravel::input(fills = Post)]`) when the form writes to a model so `create!(Post { ..form })` only fills declared fields and ignores any extra submitted fields.
- Use `Option<T>` for nullable fields (empty text inputs are trimmed and converted to `null` by default middleware). Use `Sometimes<T>` for `PATCH` or partial-update forms where a missing field means "keep current value" and `null` means "clear it".
- Use `laravel::numeric::Decimal` (never `f64`) for money and exact decimal values.
- Mark filter/search structs with `#[laravel::query]` and extract them with `Query<T>`. Fields with fallbacks (`Option<T>`, `#[default]`, `#[default = value]`) are lenient—bad or blank query parameters fall back cleanly instead of failing the page.
- Keep one-off custom rules in the handler file that uses them; place reusable `ValidationRule` implementations in `src/rules.rs` or `src/rules/`.

```rust
use laravel::model::create;
use laravel::prelude::*;

use crate::models::Post;

#[laravel::input(fills = Post)]
#[validate(authenticated)]
pub struct StorePost {
    #[validate(required, max_length(255), unique(Post::title))]
    pub title: String,
    #[validate(required)]
    pub body: String,
}

#[laravel::query]
pub struct PostFilters {
    pub search: Option<String>,
    #[default = 1]
    #[validate(min_value(1))]
    pub page: u32,
}

pub async fn store(Valid(form): Valid<StorePost>) -> laravel::Result<Redirect> {
    let post = create!(Post { ..form }).await?;

    Ok(redirect!(show, &post))
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.