import {
  ValidatorConstraint,
  ValidatorConstraintInterface,
} from 'class-validator';

@ValidatorConstraint({ name: 'notEmptyArray', async: false })
export class NotEmptyArrayConstraint implements ValidatorConstraintInterface {
  validate(array: Array<any>) {
    return Array.isArray(array) && array.length > 0;
  }

  defaultMessage() {
    return `Input cannot be an empty array`;
  }
}
