import { FieldValidation } from '@/validation/protocols' ; import { InvalidFieldError } from '@/validation/errors' ; export class CompareFieldsValidation implements FieldValidation { constructor ( readonly field , private readonly fieldToCompare ) { } validate ( input ) { return input [ this . field ] !== input [ this . fieldToCompare ] ? new InvalidFieldError ( ) : null ; } }