From 1e29fe32dde67b50cc889389c52174b38cbe4fff Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Thu, 27 Jun 2024 20:13:50 +0200 Subject: [PATCH] add lua-livr - https://fperrad.frama.io/lua-LIVR - https://luarocks.org/modules/fperrad/lua-livr --- types/lua-livr/LIVR.d.tl | 38 ++++++++++++++++++++++++++++++++ types/lua-livr/LIVR/helpers.d.tl | 9 ++++++++ 2 files changed, 47 insertions(+) create mode 100644 types/lua-livr/LIVR.d.tl create mode 100644 types/lua-livr/LIVR/helpers.d.tl diff --git a/types/lua-livr/LIVR.d.tl b/types/lua-livr/LIVR.d.tl new file mode 100644 index 0000000..babeac3 --- /dev/null +++ b/types/lua-livr/LIVR.d.tl @@ -0,0 +1,38 @@ +-- +-- https://luarocks.org/modules/fperrad/lua-livr +-- + +local record LIVR + type Data = {string:any} + type Error = string|table + type ValidatorFn = function(value: any, all: Data): any, Error + type Builder = function(builders: {string:Builder}, ...: any): ValidatorFn + type Rule = string|table + + record Alias + name: string + rules: Rule + error: string + end + + record Validator + prepare: function(self: Validator): Validator + validate: function(self: Validator, data: Data): Data, string|{string:Error} + register_rules: function(self: Validator, rules: {string:Builder}): Validator + register_aliased_rule: function(self: Validator, alias: Alias): Validator + get_rules: function(self: Validator): {string:Builder} + end + + new: function(rules: {string:Rule}, is_auto_trim: boolean): Validator + register_default_rules: function(rules: {string:Builder}) + register_aliased_default_rule: function(alias: Alias) + + default_rules: {string:Builder} + default_auto_trim: boolean + _NAME: string + _VERSION: string + _DESCRIPTION: string + _COPYRIGHT: string +end + +return LIVR diff --git a/types/lua-livr/LIVR/helpers.d.tl b/types/lua-livr/LIVR/helpers.d.tl new file mode 100644 index 0000000..65e615f --- /dev/null +++ b/types/lua-livr/LIVR/helpers.d.tl @@ -0,0 +1,9 @@ + +local record helpers + primitive_type: {string:boolean} + string_number_type: {string:boolean} + number_boolean_type: {string:boolean} + expected_type: function(rule: string, n: integer, tname: string, value: any) +end + +return helpers