function t.enum(U)assert(t.Enum(U))return function(o)local N,q=t.EnumItem(o)if not N then return false,q end if o.EnumType==U then return true else return false,string.format("\101\110\117\109 \111\102 \037\115 \101\120\112\101\099\116\101\100\044 \103\111\116 \101\110\117\109 \111\102 \037\115",tostring(U),tostring(o.EnumType))end end end do local U=t.tuple(t.callback,t.callback)function t.wrap(o,N)assert(U(o,N))return function(...)assert(N(...))return o(...)end end end

function t.enum(enum)
	assert(t.Enum(enum))
	return function(value)
		local enumItemSuccess, enumItemErrMsg = t.EnumItem(value)
		if not enumItemSuccess then
			return false, enumItemErrMsg
		end

		if value.EnumType == enum then
			return true
		else
			return false, string.format("enum of %s expected, got enum of %s", tostring(enum), tostring(value.EnumType))
		end
	end
end

do
	local checkWrap = t.tuple(t.callback, t.callback)

	--[[**
		wraps a callback in an assert with checkArgs

		@param callback The function to wrap
		@param checkArgs The functon to use to check arguments in the assert

		@returns A function that first asserts using checkArgs and then calls callback
	**--]]
	function t.wrap(callback, checkArgs)
		assert(checkWrap(callback, checkArgs))
		return function(...)
			assert(checkArgs(...))
			return callback(...)
		end
	end
end
