Skip to content

Add custom validation error messages

Thomas Flori requested to merge github/fork/Arcesilas/feature/validator into master

Created by: Arcesilas

Hi,

As proposed in #112 (closed) I've added the ability to specify custom validation error messages. I've introduced a new Validator class, and gathered the validation related features in a new WithValidator trait. Kept Argument::hasValidation() for backward compatibility (because it is public...), and marked it as deprecated. No BC change has been introduced, tests and CS ok. Updated documentation and Changelog accordingly.

Note: I think the Invalid exception should be thrown in the Validation, rather in the Operand::setValue() and Option::setValue() methods. The custom message could be defined in the validation when sending the exception. Unfortunately it would make backward compatibility harder to maintain (we would have to handle validation which return false, which means much code just for that). Maybe in 4.0...

Merge request reports