Support fallible Fill conversions that use sibling DTO fields

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

Read the Fill derive implementation and its generated field assignment hook, then reproduce the type boundary with the issue’s ContactInput example using database-sqlite and cargo check. The issue asks whether a fallible DTO-to-model mapping hook is in scope, without specifying its API or behavior; a maintainer decision is needed before implementation can be scoped.

Written by the indexing model from the issue text.

Description

In Laravel for Rust 0.2.0, a form DTO can derive Fill when its values already fit the model column types. A DTO sometimes needs a fallible conversion that reads a sibling field. For example, a national phone number needs the submitted region before it can be written as canonical text.

With the database-sqlite feature, this minimal example reproduces the type boundary:

use laravel::model::{Fill, model};

#[model]
struct Contact {
    id: i64,
    phone: String,
    region: String,
}

struct SubmittedPhone(String);

#[derive(Fill)]
#[fills(Contact)]
struct ContactInput {
    phone: SubmittedPhone,
    region: String,
}

cargo check reports error[E0277]: a SubmittedPhone can't fill a std::string::String column and says FillValue<std::string::String> is not implemented for SubmittedPhone. The current Fill derive forwards each field independently, and its assignment hook has no error return. An infallible conversion from the field alone cannot use the sibling region.

An application can normalize first and call the model's typed setter. Would a fallible DTO-to-model mapping hook be in scope for the framework? A hook taking the DTO and returning a typed column value would let applications reuse the rest of the generated field mapping while propagating conversion errors.

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.