Last error messsage

Issue #3 new
Alin Eugen Deac repo owner created an issue

Small and simple validators are not that easy to write useful error messages for. However, when you are making complex validators, that must follow complex rules, then it would be very handy if you can get the "last" error message, so that (from an outside scope) you are able to display a bit more correct error message.

Zend Framework's validators allows such, which should be looked at for inspiration.

The challenge with such an enhancement, is that you are still limited to the static methods. However this is implemented, a "get last error" message has to be reset, every time the isValid() method is invoked, to ensure that "old" messages are not returned. In addition to this, each validator has to have its own set of error messages - thus, unique error messages need to be ensured per instance.

With this in mind, perhaps a true singleton pattern needs to be considered for the base-validator

Comments (0)

  1. Log in to comment