Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: ValidateRange - programmatic inspect range #305

Open
ryanolson opened this issue Mar 10, 2024 · 1 comment
Open

Question: ValidateRange - programmatic inspect range #305

ryanolson opened this issue Mar 10, 2024 · 1 comment

Comments

@ryanolson
Copy link

ryanolson commented Mar 10, 2024

Let's say I have two objects each with a different range:

struct InputA {
    #[validate(range(min = 0, max = 1))]
    pub val: f32
}

struct InputB {
    #[validate(range(min = 1, max = 2))]
    pub val: f32
}

And now I want to convert InputA to InputB by mapping the val in the range of A to the range of B with a simple linear transformation.

Is it possible to use a From trait which can access the ranges on each val to perform the transformation?

@Keats
Copy link
Owner

Keats commented Mar 11, 2024

Nope, you can't access the validation rules programmatically currently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants