| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 | | import rules from '../rule/'; |  | import { isEmptyValue } from '../util'; |  |   |  | function type(rule, value, callback, source, options) { |  |   var ruleType = rule.type; |  |   var errors = []; |  |   var validate = rule.required || !rule.required && source.hasOwnProperty(rule.field); |  |   if (validate) { |  |     if (isEmptyValue(value, ruleType) && !rule.required) { |  |       return callback(); |  |     } |  |     rules.required(rule, value, source, errors, options, ruleType); |  |     if (!isEmptyValue(value, ruleType)) { |  |       rules.type(rule, value, source, errors, options); |  |     } |  |   } |  |   callback(errors); |  | } |  |   |  | export default type; | 
 |