Mugo Validated String
The Mugo Validated String extension adds a "Text Line (validated)" datatype to your eZ Publish installation.
It is designed to be flexible and very easy to extend so that you can add your own validation logic.
The Mugo Validated String extension adds a "Text Line (validated)" datatype to your eZ Publish installation. You can add an attribute of this datatype to any class. Whenever an object tries to set the value for this attribute, the value is validated according to the validation method selected when the class attribute was created. It is designed to be flexible and very easy to extend. You can validate via a simple regular expression, as shown in the example validators. Or, you can validate using any logic you want, such as looking up an external service to perform the validation.
A custom validator is as simple as this PHP class:
<?php class MugoSampleValidationType extends MugoValidationType { public function validate( $text ) { //the error message displayed if the check does not match $errorMessage = "This field must match a vendor name"; //if the input is matched to the accepted expression and return true if( vendorClass::lookup( $text ) ) { return true; } //otherwise, set the class errormessage and return false else { $this->errorMessage = ezpI18n::tr( 'mugovalidatedstring', $errorMessage ); return false; } } } ?>
Contribute to the code on GitHub: https://github.com/mugoweb/mugovalidatedstring