Skip to content

Commit 7235f80

Browse files
committed
Update the readme.
1 parent 13442e7 commit 7235f80

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,24 @@ ClassValidator.isExtend(Class, obj);
6262
ClassValidator.isExtend(Object, B); //return true;
6363
```
6464

65+
* **hasMethod**
66+
67+
Defined: `function hasMethod(classType: Class, methodName: String): Boolean`
68+
69+
Describe: Check the class have this method.
70+
71+
Examples:
72+
73+
```js
74+
class Super { superMethod() {} };
75+
class Sub extends Super { subMethod() {} };
76+
77+
ClassValidator.hasMethod(SubClass, 'subMethod'); //return true;
78+
ClassValidator.hasMethod(SubClass, 'superMethod'); //return true;
79+
ClassValidator.hasMethod(SubClass, 'unknownMethod'); //return true;
80+
ClassValidator.hasMethod(SuperClass, 'subMethod'); //return true;
81+
```
82+
6583
### FunctionValidator
6684

6785
* **isFunction**
@@ -153,7 +171,7 @@ ClassValidator.isExtend(Class, obj);
153171

154172
Defined: `function hasAnyProperty(obj: Object): Boolean`
155173

156-
Describe: Check the obj is not a empty object.
174+
Describe: Check the obj has any property.
157175

158176
Examples:
159177

@@ -164,6 +182,23 @@ ClassValidator.isExtend(Class, obj);
164182
ObjectValidator.hasAnyProperty({a: 1}); //return true;
165183
```
166184

185+
* **hasProperty**
186+
187+
Defined: `function hasProperty(obj: Object, propertyName: String): Boolean`
188+
189+
Describe: Check the obj has property.
190+
191+
Examples:
192+
193+
```js
194+
var obj = { have: 1 };
195+
196+
ObjectValidator.hasProperty(obj, 'have'); //return true;
197+
ObjectValidator.hasProperty(null, 'have'); //return false;
198+
ObjectValidator.hasProperty(undefined, 'have'); //return false;
199+
ObjectValidator.hasProperty(obj, 'doNotHave'); //return false;
200+
```
201+
167202
### StringValidator
168203

169204
* **isString**

0 commit comments

Comments
 (0)