Skip to content

Commit 006d78c

Browse files
committed
refactor(mapper): separate type and format in numberToTime
type only accepts enum, format handles time pattern
1 parent ae1c306 commit 006d78c

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

lib/schemas/common/mapper.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@ const baseMapperSchema = [
2222
properties: {
2323
type: {
2424
type: 'string',
25-
oneOf: [
26-
{
27-
enum: ['minute', 'hour', 'day', 'week']
28-
},
29-
{
30-
pattern: '^([H]{1,2}|[m]{1,2}|[s]{1,2})(:([H]{1,2}|[m]{1,2}|[s]{1,2}))*$'
31-
}
32-
],
33-
default: 'hour'
25+
enum: ['minute', 'hour', 'day', 'week']
26+
},
27+
format: {
28+
type: 'string',
29+
pattern: '^([H]{1,2}|[m]{1,2}|[s]{1,2})(:([H]{1,2}|[m]{1,2}|[s]{1,2}))*$'
3430
}
3531
},
3632
additionalProperties: false

tests/mocks/schemas/browse.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,8 @@
13301330
"mapper": {
13311331
"name": "numberToTime",
13321332
"props": {
1333-
"type": "HH:mm:ss"
1333+
"type": "hour",
1334+
"format": "HH:mm:ss"
13341335
}
13351336
}
13361337
},

tests/mocks/schemas/expected/browse.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,8 @@
16931693
"mapper": {
16941694
"name": "numberToTime",
16951695
"props": {
1696-
"type": "HH:mm:ss"
1696+
"type": "hour",
1697+
"format": "HH:mm:ss"
16971698
}
16981699
},
16991700
"attributes": {

0 commit comments

Comments
 (0)