Yii 1.1: is-xml-validator

Validates if an uploaded file is XML
2 followers

Use this extension to validate if an uploaded file is a XML file.

It will try to open the file with SimpleXML and if it fails it will set the libxml errors to the attribute.

Requirements

Created and tested with Yii 1.1.9

Usage

Copy the attached file to the extensions folder (Example: protected/extensions/validators).

In your model, add something like this:

public function rules() {
    return array(
        ...
        array('xmlFile', 'file', 'allowEmpty' => false, 'types' => 'xml'),
        array('xmlFile', 'ext.validators.isXmlValidator'),
        ...
    );
  }

Be the first person to leave a comment

Please to leave your comment.

Create extension