zio-schema
zio-schema copied to clipboard
Add validation constructor to validate times
ISSUE
There is no constructor for zio.schema.validation.Validation
which can validate a local time in some specified format.
SOLUTION
Using other constructors which already exist in zio.schema.validation.Validation
(which include regex validation, string length checking, and numeric range checking), introduce a new constructor that satisfies the requirements of this issue.
object Validation {
...
def time(format: String): Validation[String] = ???
}
...
val validation: Validation[String] = Validation.time("hh:mm:ss")
IMPACT
Increasing the number of constructors for Validation
will make it far easier to use the validation
package to
WHERE TO LOOK
PROBLEMATIC ISSUES
Issue #248 must be completed first, or at least, this issue must be based off of #244.
I pick this one up for the hackathon.
Does it need to support the same stuff as the DateTimeFormatter?
a am-pm-of-day text PM
h clock-hour-of-am-pm (1-12) number 12
K hour-of-am-pm (0-11) number 0
k clock-hour-of-am-pm (1-24) number 0
H hour-of-day (0-23) number 0
m minute-of-hour number 30
s second-of-minute number 55
S fraction-of-second fraction 978
A milli-of-day number 1234
n nano-of-second number 987654321
N nano-of-day number 1234000000
@tewecske Do as much as you are willing. You may be able to just piggyback atop DateTimeFormatter
, rather than implementing any new parsing. However, I didn't take a close look to see if they expose the (parsed) data.
Unfortunately the parsed data only available from DateTimeFormatter.toString
as string. Like Value(HourOfDay,2)':'Value(MinuteOfHour,2)':'Value(SecondOfMinute,2)
.