We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
2.1.0
It is currently impossible to validate dates in ISO8601 format.
Day.js requires ISO8601 format when using the dayjs(value) function. documentation
dayjs(value)
but this plugin force to use dayjs(value, formats, true) and there is no format for ISO8601 string in available formats
dayjs(value, formats, true)
ISO8601 format is most common format for dates, can we use it in vine date validator please?
No response
The text was updated successfully, but these errors were encountered:
I created an adonisjs provider to handle ISO8601 dates if anyone needs it:
import vine, { symbols, Vine, VineDate } from '@vinejs/vine'; import { messages } from '@vinejs/vine/defaults'; import dayjs from 'dayjs'; const isIsoDate = vine.createRule((value, _, field) => { if (typeof value !== 'string') { field.report(messages.date, 'date', field); return; } const dateTime = dayjs(value); if (!dateTime.isValid()) { field.report(messages.date, 'date', field); return; } field.meta.$value = dateTime; field.mutate(dateTime.toDate(), field); }); class VineDateIso extends VineDate { constructor() { super(undefined, [isIsoDate()]); } [symbols.UNIQUE_NAME] = 'vine.dateIso'; [symbols.IS_OF_TYPE] = (value: any) => { if (typeof value !== 'string') { return false; } return dayjs(value).isValid(); }; } declare module '@vinejs/vine' { interface Vine { dateIso(): VineDateIso; } } export default class VineDateIsoProvider { /** * The container bindings have booted */ async boot() { Vine.macro('dateIso', () => new VineDateIso()); } }
Sorry, something went wrong.
fe61951
thetutlage
No branches or pull requests
Package version
2.1.0
Describe the bug
It is currently impossible to validate dates in ISO8601 format.
Day.js requires ISO8601 format when using the
dayjs(value)
function. documentationbut this plugin force to use
dayjs(value, formats, true)
and there is no format for ISO8601 string in available formatsISO8601 format is most common format for dates, can we use it in vine date validator please?
Reproduction repo
No response
The text was updated successfully, but these errors were encountered: