You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							20 lines
						
					
					
						
							698 B
						
					
					
				
			
		
		
	
	
							20 lines
						
					
					
						
							698 B
						
					
					
				import * as util from '../util'; | 
						|
 | 
						|
/** | 
						|
 *  Rule for validating required fields. | 
						|
 * | 
						|
 *  @param rule The validation rule. | 
						|
 *  @param value The value of the field on the source object. | 
						|
 *  @param source The source object being validated. | 
						|
 *  @param errors An array of errors that this rule may add | 
						|
 *  validation errors to. | 
						|
 *  @param options The validation options. | 
						|
 *  @param options.messages The validation messages. | 
						|
 */ | 
						|
function required(rule, value, source, errors, options, type) { | 
						|
  if (rule.required && (!source.hasOwnProperty(rule.field) || util.isEmptyValue(value, type || rule.type))) { | 
						|
    errors.push(util.format(options.messages.required, rule.fullField)); | 
						|
  } | 
						|
} | 
						|
 | 
						|
export default required; |