is-xml-validator Validates if an uploaded file is XML

  1. Requirements
  2. Usage

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'),
        ...
    );
  }

1 0
2 followers
409 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Validation
Developed by: jmariani
Created on: Jan 27, 2012
Last updated: 12 years ago

Downloads

show all

Related Extensions