Skip to content

Commit

Permalink
fix(QDate/QTime): harden the modelValue validation
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed May 3, 2024
1 parent e3e45df commit 69ee36a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ui/src/components/date/QDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ export default createComponent({
...useFormProps,
...useDarkProps,

modelValue: {
required: true,
validator: val => typeof val === 'string' || Array.isArray(val) === true || Object(val) === val || val === null
},

multiple: Boolean,
range: Boolean,

title: String,
subtitle: String,

mask: {
...useDatetimeProps.mask,
// this mask is forced
// when using persian calendar
default: 'YYYY/MM/DD'
Expand Down
4 changes: 1 addition & 3 deletions ui/src/components/date/use-datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { pad } from '../../utils/format/format.js'
const calendars = [ 'gregorian', 'persian' ]

export const useDatetimeProps = {
modelValue: {
required: true
},
// should define modelValue in the target component

mask: {
type: String
Expand Down
6 changes: 6 additions & 0 deletions ui/src/components/time/QTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ export default createComponent({
...useFormProps,
...useDatetimeProps,

modelValue: {
required: true,
validator: val => typeof val === 'string' || val === null
},

mask: {
...useDatetimeProps.mask,
default: null
},

Expand Down

0 comments on commit 69ee36a

Please sign in to comment.