Replies: 3 comments
-
hope this help for dob // In your validator
import { DateTime } from 'luxon';
...
dob: vine.date().optional().transform(value => DateTime.fromJSDate(value))
... |
Beta Was this translation helpful? Give feedback.
-
I guess we can look at this as a feature request or a bug. Since the framework uses Option 1: We can create custom rule to transform to const schema = vine.object({
date: vine.date().luxon(),
}) Option 2: We can create custom schema type const schema = vine.object({
date: vine.dateTime(), // or vine.luxonDateTime()
}) Option 3: We can override the default date schema type (but I'm not sure if this is possible) const schema = vine.object({
date: vine.date(), // convert value to DateTime
}) If someone from the core team gives feedback and recommendations, we may be able to make some contribution. |
Beta Was this translation helpful? Give feedback.
-
My solution is use transform
|
Beta Was this translation helpful? Give feedback.
-
I dont have this issue in v5, but in v6 is a bit confusing and i hope someone can give a clue as whats is going on.
So let's say in mysql database theres users table with fields dob as date and last_seen as datetime.
heres my model declaration:
the (vine) validators:
controllers, to store data:
in editor, got this warning in line 4: Types of property 'dob' are incompatible. Type 'Date | null | undefined' is not assignable to type 'DateTime | null | undefined'. Type 'Date' is missing the following properties from type 'DateTime': get, getPossibleOffsets, isValid, invalidReason, and 71 more.ts(2345)
as for sending post to the endpoint, with parameter dob e.g. "2000-10-10" i got the following error message: "Invalid value for "User.dob". The value must be an instance of "luxon.DateTime""
any idea?
Beta Was this translation helpful? Give feedback.
All reactions