Skip to content

Commit 9cb83e2

Browse files
committed
feat(api): Further improve validations
1 parent 4921932 commit 9cb83e2

File tree

7 files changed

+16
-21
lines changed

7 files changed

+16
-21
lines changed

ui/build/build.api.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,19 @@ const astExceptions = {
422422

423423
function validateArray (name, key, property, expected, propApi) {
424424
const apiVal = propApi[property]
425+
425426
if (expected.length === 1 && expected[0] === apiVal) {
426427
return
427428
}
429+
430+
const expectedVal = expected.filter(t => t.startsWith('__') === false)
431+
428432
if (
429433
!Array.isArray(apiVal) ||
430-
apiVal.length !== expected.length ||
431-
!expected.every(t => apiVal.includes(t))
434+
apiVal.length !== expectedVal.length ||
435+
!expectedVal.every(t => apiVal.includes(t))
432436
) {
433-
logError(`${name}: wrong definition for prop "${key}" on "${property}": expected ${expected} but found ${apiVal}`)
437+
logError(`${name}: wrong definition for prop "${key}" on "${property}": expected ${expectedVal} but found ${apiVal}`)
434438
process.exit(1)
435439
}
436440
}
@@ -491,7 +495,7 @@ function fillAPI (apiType) {
491495
process.exit(1)
492496
}
493497
}
494-
if (definition.required && Boolean(definition.required) !== propApi.required) {
498+
if (key !== 'value' && definition.required && Boolean(definition.required) !== propApi.required) {
495499
logError(`${name}: wrong definition for prop "${key}" on "required": expected "${definition.required}" but found "${propApi.required}"`)
496500
process.exit(1)
497501
}

ui/src/components/btn-toggle/QBtnToggle.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"type": "Any",
1111
"desc": "Model of the component; Either use this property (along with a listener for 'input' event) OR use v-model directive",
1212
"examples": [ "v-model=\"selected\"" ],
13-
"category": "model",
14-
"required": true
13+
"category": "model"
1514
},
1615

1716
"options": {

ui/src/components/option-group/QOptionGroup.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"extends": "value",
55
"type": "Any",
66
"examples": [ "v-model=\"group\"" ],
7-
"category": "model",
8-
"required": true
7+
"category": "model"
98
},
109

1110
"options": {

ui/src/components/popup-edit/QPopupEdit.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"extends": "value",
55
"type": "Any",
66
"examples": [ "v-model=\"myValue\"" ],
7-
"category": "model",
8-
"required": true
7+
"category": "model"
98
},
109

1110
"title": {

ui/src/components/rating/QRating.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"value": {
1010
"extends": "value",
1111
"type": "Number",
12-
"examples": [ ":value=\"2\"" ],
13-
"required": true
12+
"examples": [ ":value=\"2\"" ]
1413
},
1514

1615
"max": {

ui/src/components/virtual-scroll/QVirtualScroll.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@ export default Vue.extend({
2929
default: () => []
3030
},
3131

32-
itemsFn: {
33-
type: Function
34-
},
35-
36-
itemsSize: {
37-
type: Number
38-
},
32+
itemsFn: Function,
33+
itemsSize: Number,
3934

4035
scrollTarget: {
4136
default: void 0

ui/src/components/virtual-scroll/QVirtualScroll.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
},
2323

2424
"items-size": {
25-
"type": [ "String", "Number"],
25+
"type": "Number",
2626
"desc": "Number of available items in the list; Required and used only if 'itemsFn' is provided",
2727
"default": "void 0",
2828
"examples": [
29-
"items-size=\"100000\"",
29+
":items-size=\"100000\"",
3030
":items-size=\"500\""
3131
],
3232
"category": "content"

0 commit comments

Comments
 (0)