saplingjs / sapling

🌿 Sapling is a Node.js framework for faster-than-light web development.
https://www.saplingjs.com
MIT License
14 stars 0 forks source link

Timeframe length validator for Date fields #73

Open groenroos opened 3 years ago

groenroos commented 3 years ago

Add a model property that allows the developer to validate incoming Date fields against the current date; for example, date must be more than 18 years ago, or date must be less than 3 months ago.

Would be useful for storing dates of birth where there's also an age requirement.

Need to figure out a clear and concise notation for this, since I don't want it to be like PHP's date() where every dang time you need to use it, you have to look up the magic hieroglyphs that correspond to the different date elements.

groenroos commented 2 years ago

Probably most likely want to use some NLP based formatting here, like chrono, to avoid the definition of the constraints being too hieroglyphic.

groenroos commented 2 years ago

Probably most likely want to use some NLP based formatting here, like chrono, to avoid the definition of the constraints being too hieroglyphic.

And probably find a way to cache the parsed definition, so that it's not parsing NLP each time Sapling touches the model.