Skip to content

Commit 13eb1d4

Browse files
committed
feat(new converter): boolean
1 parent db9b710 commit 13eb1d4

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ All methods convert the attribute's value to a type and returns it.
128128
The first param is the attribute's value which is always a string.
129129

130130
* Methods
131+
* boolean(val) :boolean
131132
* valueless(val) :boolean
132133

133134
```js

src/client/scripts/public/props/converters.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
- The first param is the attr val which is always a string.
99
*************************************************************/
1010
const Converters = {
11+
boolean(val) { // :boolean
12+
return /^true$/i.test(val);
13+
},
1114
valueless(val) { // :boolean
1215
val = val.trim();
1316
if (!val) return true; // valueless attr is empty string

0 commit comments

Comments
 (0)