function t.array(X)assert(t.callback(X))local F=t.values(X)return function(X)local E,W=arrayKeysCheck(X)if E==false then return false,string.format("\091\097\114\114\097\121\093 \037\115",W or"")end local k=0 for X in ipairs(X)do k=k+1 end for X in pairs(X)do if X<1 or X>k 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(X))end end local S,G=F(X)if not S then return false,string.format("\091\097\114\114\097\121\093 \037\115",G or"")end return true end end

	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
