import { IValidator , IRule } from '../validation' ; /**
 * Rule options.
 */ export interface IRequiredRule extends IRule { required ? : boolean ; } const DEFAULT_MESSAGE = 'This field is required' ; param rule returns { ( opts : any ) => boolean | string } export const required = ( rule ? ) : IValidator < any > => { if ( typeof rule !== 'string' && rule !== undefined && rule . required === false ) { return ( ) => true ; } return opts => { return opts . value || opts . value === 0 ? true : ( typeof rule === 'string' ? rule : rule && rule . msg ) || DEFAULT_MESSAGE ; } ; } ;