Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  KWALIFY (3)

.ds Aq ’


Kwalify - Kwalify schema for data structures



  use Kwalify qw(validate);
  validate($schema, $data);

Typically used together with YAML or JSON:

  use YAML;
  validate(YAML::LoadFile($schema_file), YAML::LoadFile($data_file));

  use JSON;
  validate(jsonToObj($schema_data), jsonToObj($data));


Kwalify is a Perl implementation for validating data structures against the Kwalify schema. For a schema definition, see <>, but see also below SCHEMA DEFINITION.

validate($schema_data, CW$data)

Validate $data according to Kwalify schema specified in $schema_data. Dies if the validation fails.

<B>validateB> may be exported.


The original schema definition document is not very specific about types and behaviour. Here’s how <B>Kwalify.pmB> implements things:
pattern Perl regular expressions are used for patterns. This may or may not be compatible with other Kwalify validators, so restrict to simple regular expression constructs to be compatible with other validators.
str Any defined value which is <B>notB> a number. Most probably you will want to use <B>textB> instead of <B>strB>.
int A possibly signed integer. Note that scientific notation is not supported, and it is also not clear whether it should be supported.
float A possibly signed floating value with a mandatory decimal point. Note that scientific notation is also not supported here.
bool The values <B>yesB>, <B>trueB>, and <B>1B> for true values and the values <B>noB>, <B>falseB>, and <B>0B> for false values are allowed. The ruby implementation possibly allows more values, but this is not documented.

Note that this definition is problematic, because for example the string <B>noB> is a true boolean value in Perl. So one should stick to <B>0B> and <B>1B> as data values, and probably define an additional <B>patternB> or <B>enumB> to ensure this:

    type: bool
    enum: [0, 1]

scalar Currently the same as <B>textB>, but it’s not clear if this is correct.
date A string matching /^\d{4}-\d{2}-\d{2}$/ (i.e. YYYY-MM-DD). Note that no date range checks are done (yet).
time A string matching /^\d{2}:\d{2}:\d{2}$/ (i.e. HH:MM:SS). Note that no time range checks are done (yet).
timestamp Not supported --- it is not clear what this is supposed to be.
assert Currently not supported by the Perl implementation.
classname Previously defined what is now class, see <>.
class Currently not used, as there’s no genclass action.
default Currently not used, as there’s no genclass action.


As <B>Kwalify.pmB> is a pure validator and de-coupled from a parser (in fact, it does not need to deal with YAML at all, but just with pure perl data structures), there’s no connection to the original validated document. This means that no line numbers are available to the validator. In case of validation errors the validator is only able to show a path-like expression to the data causing the error.


Slaven ReziX, <>


Copyright (C) 2006,2007,2008,2009,2010 by Slaven ReziX

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.


pkwalify, kwalify(1).

Other non-XML schema languages: <>

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 KWALIFY (3) 2011-02-24

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.