Skip to content

Commit 7fe8355

Browse files
committed
#195 - support for metadata value matchers
- fixes in value converters from various types of metadata to types accepted by matchers (string, bool, float, int)
1 parent be0463d commit 7fe8355

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/custom-sort/value-converters.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ export class ValueConverters implements ValueConvertersAPI {
7575
}
7676
if ('string' === typeof v) {
7777
const v2l = v.trim().toLowerCase()
78-
return (v2l === 'true' || v2l === 'yes') ? true : ((v2l === 'false' || v2l === 'no') ? false : undefined)
78+
return (v2l === 'true' || v2l === 'yes' || v2l === '1')
79+
?
80+
true
81+
: ((v2l === 'false' || v2l === 'no' || v2l === '0') ? false : undefined)
7982
}
8083
return undefined // We ignore metadata values of Array type
8184
}

src/test/unit/value-converters.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ describe('toBooleanConverter', () => {
2525
['false', false],
2626
['False', false],
2727
['fALSE', false],
28+
['1', true],
29+
['0', false],
2830
[1, true],
2931
[1000, true],
3032
[-4356, true],
@@ -40,8 +42,8 @@ describe('toBooleanConverter', () => {
4042
it.each([
4143
'',
4244
' ',
43-
'1',
44-
'0',
45+
'10',
46+
'00',
4547
'-',
4648
'true1',
4749
undefined,

0 commit comments

Comments
 (0)