function t.array(C)assert(t.callback(C))local v=t.values(C)return function(C)local o,X=arrayKeysCheck(C)if o==false then return false,string.format("\091\097\114\114\097\121\093 \037\115",X or"")end local R=0 for C in ipairs(C)do R=R+1 end for C in pairs(C)do if C<1 or C>R then return false,string.format("\091\097\114\114\097\121\093 \107\101\121 \037\115 \109\117\115\116 \098\101 \115\101\113\117\101\110\116\105\097\108",tostring(C))end end local q,J=v(C)if not q then return false,string.format("\091\097\114\114\097\121\093 \037\115",J or"")end return true end end
--[[**
		ensures value is an array and all values of the array match check

		@param check The check to compare all values with

		@returns A function that will return true iff the condition is passed
	**--]]
function t.array(check)
	assert(t.callback(check))
	local valuesCheck = t.values(check)

	return function(value)
		local keySuccess, keyErrMsg = arrayKeysCheck(value)
		if keySuccess == false then
			return false, string.format("[array] %s", keyErrMsg or "")
		end

		-- # is unreliable for sparse arrays
		-- Count upwards using ipairs to avoid false positives from the behavior of #
		local arraySize = 0

		for _ in ipairs(value) do
			arraySize = arraySize + 1
		end

		for key in pairs(value) do
			if key < 1 or key > arraySize then
				return false, string.format("[array] key %s must be sequential", tostring(key))
			end
		end

		local valueSuccess, valueErrMsg = valuesCheck(value)
		if not valueSuccess then
			return false, string.format("[array] %s", valueErrMsg or "")
		end

		return true
	end
end
