lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks for pointing it out! I'll patch a fix for that today. =)


2014-03-12 7:46 GMT-03:00 Thijs Schreijer <thijs@thijsschreijer.nl>:

Looks nice but…

 

> do

>> v = require('valua')

>> t = v:new().type("table").empty()

>> print(t({}))

>> end

...Files (x86)\LuaRocks\systree\share\lua\5.1\valua.lua:77: bad argument #1 to 'len' (string expected, got table)

stack traceback:

        [C]: in function 'len'

        ...Files (x86)\LuaRocks\systree\share\lua\5.1\valua.lua:77: in function 'empty'

        ...Files (x86)\LuaRocks\systree\share\lua\5.1\valua.lua:83: in function <...Files (x86)\LuaRocks\systree\share\l

ua\5.1\valua.lua:82>

        (tail call): ?

        ...Files (x86)\LuaRocks\systree\share\lua\5.1\valua.lua:50: in function 't'

        stdin:4: in main chunk

        [C]: ?

> 

 

 

From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On Behalf Of Etiene Dalcol
Sent: dinsdag 11 maart 2014 21:59
To: Lua mailing list
Subject: [ANN] Valua 0.2 - Validation for Lua

 

Hello, everyone!

I made this chained validation module. It's called valua and was originally bundled with another project of mine (Sailor MVC), but since it works separately, I sent it to the LuaRocks repository. 

The validation objects are reusable and if a test fails at the beginning of the chain, it will break the chain and won't test the rest of it.

Example:
    local valua = require "valua"

    local test = valua:new().integer().min(18)
    test(23.7) -- false

    test(5) -- false

    test(19) -- true

The license is MIT, use at will, I hope you enjoy it! =)
https://github.com/Etiene/valua

Cheers,
Etiene.