Home

Awesome

Valua - Validation for Lua

Build Status Coverage Status

A module for making chained validations. Create your objects, append your tests, use and reuse it!

Originally bundled with Sailor MVC Web Framework, now released as a separated module. https://github.com/Etiene/sailor

This module provides tools for validating values, very useful in forms, but also usable elsewhere. It works in appended chains. Create a new validation object and start chaining your test functions. If your value fails a test, it breaks the chain and does not evaluate the rest of it. It returns a boolean and an error string (nil when tests succeeded).

Valua is also available through luarocks

luarocks install valua

Usage

Example 1 - Just create, chain and use:

valua:new().type("string").len(3,5)("test string!") -- false, "should have 3-5 characters"

Example 2 - Create, chain and later use it multiple times:

local reusable_validation = valua:new().type("string").len(3,5)
reusable_validation("test string!") -- false, "should have 3-5 characters"
reusable_validation("test!") -- true

Current validation functions

Copyright (c) 2014 Etiene Dalcol

http://etiene.net

http://twitter.com/etiene_d

License: MIT

Inspired by Respect Validation for PHP

https://github.com/Respect/Validation