You will be validated. Resistance is futile.

It has been over a week since I posted about any MediaWiki stuff, which can very well be a record since I started my blog. The reason for this is cause I’ve been busy with a lot of projects. You’ll hear about them all later on, but now I just want to provide an overview of the work I’ve been doing on my new MediaWiki extension: Validator.

Validator is an extension that makes parameter validation functionality available to other extensions. This enables other extensions to validate parameters, set them to their defaults, and generate error messages, while only defining the parameters and their criteria. The goal of this extension is to facilitate the handling of parameters in other extension, and generalize the error output. By itself, it does not add any functionality to the user end.

The main functionality is:

  • Parameter validation: Parameters that are provided in an array where the keys represent their name, and the values their value, can easily be validated against a set of criteria. During this validation, errors and their types will be stored, and invalid parameters will be separated from valid ones. The only thing an other extension needs to do is define the criteria to validate against. A set of criteria types (which include check to see if something is a number, is within a range, or in an array) is provided by Validator, and can be used without any extra coding. When a criteria type that is not supported is required, you can hook into the Validator criteria types and add your own validation functions.
  • Default value handling: Parameters that are invalid, or simply not provided, can be set to their default values. These default values need to be specified by the extension the parameters belong to.
  • Error handling: Since the errors and their types are stored during validation, you can create error messages by retrieving this data and parsing it. Validator also provides a manager class that can provide you with a list of internationalized and specific errors. Via a validation level setting Validator provides, you can determine how the errors should be reflected on your wiki page. This can go from completely ignoring any errors to showing a complete list of all errors underneath the regular output, or even hiding the regular output and only showing the errors.

Validator has not yet been released, but will be soon. Although not all documentation is ready yet, most of the information needed to use it can already be found in the implementation section of the documentation. Both the development versions of Maps and Semantic Maps are currently using Validator for their parameter handling. The next release of those extensions, 0.5, will therefore feature strict parameter validation, and be dependent on Validator.

Oh, and I got the 60000th MediaWiki commit with the changes I made to Maps to work with the last alpha of Validator – wooot! 🙂

One Comment on “You will be validated. Resistance is futile.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.