Browse Source

fix(gui): year validation correction

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4514/head
Pranav C 2 years ago
parent
commit
e51be1b2f2
  1. 10
      packages/nc-gui/composables/useMultiSelect/convertCellData.ts

10
packages/nc-gui/composables/useMultiSelect/convertCellData.ts

@ -46,16 +46,18 @@ export default function convertCellData(args: { from: UITypes; to: UITypes; valu
return parsedTime.format(dateFormat) return parsedTime.format(dateFormat)
} }
case UITypes.Year: { case UITypes.Year: {
if (/^\d+$/.test(value)) {
return +value
}
const parsedDate = dayjs(value) const parsedDate = dayjs(value)
if (!parsedDate.isValid()) { if (parsedDate.isValid()) {
return parsedDate.format('YYYY') return parsedDate.format('YYYY')
} }
if (/^\d+$/.test(value)) {
throw new Error('Not a valid year value') throw new Error('Not a valid year value')
} }
return value
}
case UITypes.Attachment: { case UITypes.Attachment: {
let parsedVal let parsedVal
try { try {

Loading…
Cancel
Save