Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(validators) fix len validator #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/resty/validation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local upper = string.upper
local find = string.find
local gsub = string.gsub
local sub = string.sub
local len = utf8 and utf8.len or function(s) return select(2, gsub(s, '[^\x80-\xC1]', '')) end
local len = utf8 and utf8.len or function(s) return select(2, gsub(s, "[^\128-\193]", "")) end
local iotype = io.type
local math = math
local mathtype = math.type
Expand Down Expand Up @@ -371,7 +371,7 @@ function factory.starts(starts)
end
function factory.ends(ends)
return function(value)
return ends == '' or sub(value, -len(ends)) == ends
return ends == "" or sub(value, -len(ends)) == ends
end
end
function factory.reverse()
Expand Down Expand Up @@ -623,7 +623,6 @@ function group:requisite(r)
local c = #r
self[#self+1] = function(fields)
local n = c
local valid = true
for i = 1, c do
local f = r[i]
if not fields[f] then
Expand Down Expand Up @@ -657,7 +656,6 @@ function group:requisites(r, n)
local n = n or c
self[#self+1] = function(fields)
local j = c
local valid = true
for i = 1, c do
local f = r[i]
if not fields[f] then
Expand Down