Document db::Json types as input fields, or add a public derive for them

Open
#818 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@donejeh is already working on this.

Since Dec 4, 2026.

  • #837 by @donejeh — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust

Research direction

Read the validation guide’s “Nested objects” section and the JSON columns section in docs/models.md, then compare their descriptions with the behavior noted in macros/database/src/binding.rs around line 55. The issue offers documenting db::Json input fields or adding a public derive; an open pull request, #837, is already linked. Done means the chosen approach is documented or exposed publicly and its behavior is clear to package authors.

Written by the indexing model from the issue text.

Description

Problem

A package can give a type to an application, and the application puts the type in its own #[laravel::input] struct. For example, the type holds a signed payload that a browser API returns. The type wraps a type from another crate, so it cannot be a #[laravel::input] struct with rules on each field.

The only method that I found is to derive db::Json on a tuple struct:

#[derive(Debug, Clone, Serialize, Deserialize, db::Json)]
#[serde(transparent)]
pub struct SignedPayload(other_crate::Payload);

#[laravel::input]
pub struct Confirm {
    payload: SignedPayload,
}

The method works because the db::Json derive implements laravel::validation::__private::Project for an enum or a tuple struct. The comment in binding.rs L55 says: "A form field of the type validates as the JSON it serializes to."

The documentation does not describe this behavior:

  • The JSON columns section describes db::Json only for a database column.
  • The nested objects section says that a nested object is a #[laravel::input] struct.
  • The Project trait is in a __private module.

A package that uses this behavior depends on an internal detail, and a patch release can break it. Also, a type that never goes into a database must derive a database trait.

Proposal

Do one of these two things:

  1. Document the behavior in the validation guide. Say that a field of a db::Json enum or tuple struct validates as the JSON that it serializes to.
  2. Add a public derive for an input field that has no rules on its own fields, for example #[derive(validation::Opaque)]. Then db::Json stays a database derive.

Option 2 is better for packages. Option 1 is sufficient.

Dominant language
Rust
Stars
847
Forks
174
Avg merge
5h 40m
Merged PRs (30d)
167

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from laravel/rust-framework

All issues in laravel/rust-framework

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.