import * as _ from "lodash" ; import { Validator , ValidationError } from "../types" ; export class NotEmptyValidator implements Validator { public constructor ( protected field , protected valueProperty ? , protected message ? ) { } public validate ( value ) { const valueToValidate = this . valueProperty ? _ . get ( value , this . valueProperty ) : value ; if ( _ . isEmpty ( valueToValidate ) ) { throw new ValidationError ( this . message || `${ _ . upperFirst ( this . field ) } must be set` ) ; } } }