typical
typical copied to clipboard
Custom validation feature request
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.
@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.")
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?