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

Custom validation feature request #31

Open
jae-lee opened this issue Feb 7, 2020 · 2 comments
Open

Custom validation feature request #31

jae-lee opened this issue Feb 7, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request
Projects

Comments

@jae-lee
Copy link

jae-lee commented Feb 7, 2020

Description

Would like to see a feature to implement custom validations that could span multiple fields. For example:

Let's say you had a vacation start date and vacation end date field. Vacation start date should be before vacation end date.

@seandstewart seandstewart self-assigned this Feb 7, 2020
@seandstewart seandstewart added the enhancement New feature or request label Feb 7, 2020
@kfollesdal
Copy link
Contributor

kfollesdal commented Mar 20, 2020

@jae-lee maybe I misunderstand, but can you use post_init to validate dependent fields?

import typic
from datetime import datetime


@typic.klass
class DateCheck:
    start: datetime
    end: datetime

    def __post_init__(self):
        if self.start > self.end:
            raise ValueError("Start date have to be before end date.")

@seandstewart seandstewart added this to To do in v2.1 Apr 30, 2020
@seandstewart seandstewart added this to the Typic 2.1 milestone Apr 30, 2020
@seandstewart seandstewart removed this from To do in v2.1 Jan 5, 2021
@seandstewart seandstewart added this to To do in v2.6 via automation Jan 5, 2021
@seandstewart seandstewart removed this from the Typic 2.1 milestone Jan 5, 2021
@MVrachev
Copy link

I agree this will be an awesome feature.
Many times you want a deeper validation beyond type checks which you can only implement.

What is the status of this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
v2.6
To do
Development

No branches or pull requests

4 participants