Extensions and Tools » Extensions » Mugo Validated String

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


Have something in mind? We'd love to chat about it.

We're always open to being involved in challenging and interesting projects. If you have something that might fit the bill - let's talk.

Hi, we're Mugo Web - Nice to meet you!

We're a group of web experts who solve complex web problems.

Learn more about us »

eZ Publish Extensions

We extend eZ Publish beyond its limits to make it a platform that's truly built around our client's work flow.

Learn more about our extensions »

Yes - we can do that.

Many years of experience with complex websites allows us to offer total solutions.

Learn more about what we can do »
© 2008 - 2019 Mugo Web. All rights reserved.