### Question:
RequiredFieldMaxLengthValidator implements ObjectValidator<StringMaxLengthValidator.MaxLengthRequirement> { @Override public void validate(@NotNull StringMaxLengthValidator.MaxLengthRequirement object, @NotNull MessageError messageError) { if (StringUtils.isBlank(object.getField())) { errorBuildingService.enrichMessageError(messageError, TppMessageInformation.of(FORMAT_ERROR_EMPTY_FIELD, object.getFieldName())); } else { stringMaxLengthValidator.validate(object, messageError); } }  @Override void validate(@NotNull StringMaxLengthValidator.MaxLengthRequirement object, @NotNull MessageError messageError);  }### Answer:
@Test void validate_success() { MaxLengthRequirement panField = new MaxLengthRequirement("1234567890", "PAN", 35); requiredFieldMaxLengthValidator.validate(panField, messageError); assertTrue(messageError.getTppMessages().isEmpty()); }
@Test void validate_account_empty_field() { MaxLengthRequirement panField = new MaxLengthRequirement(null, "PAN", 35); requiredFieldMaxLengthValidator.validate(panField, messageError); assertFalse(messageError.getTppMessages().isEmpty()); assertEquals(MessageCategory.ERROR, messageError.getTppMessage().getCategory()); assertEquals(MessageErrorCode.FORMAT_ERROR_EMPTY_FIELD, messageError.getTppMessage().getMessageErrorCode()); assertArrayEquals(new String[] {"PAN"}, messageError.getTppMessage().getTextParameters()); }
@Test void validate_long_field_name() { MaxLengthRequirement panField = new MaxLengthRequirement("1234567890", "PAN", 9); requiredFieldMaxLengthValidator.validate(panField, messageError); assertFalse(messageError.getTppMessages().isEmpty()); assertEquals(MessageCategory.ERROR, messageError.getTppMessage().getCategory()); assertEquals(MessageErrorCode.FORMAT_ERROR_OVERSIZE_FIELD, messageError.getTppMessage().getMessageErrorCode()); assertArrayEquals(new Object[] {"PAN", 9}, messageError.getTppMessage().getTextParameters()); }