Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --RemoteRequestValidator module:
- local RemoteParam = require(script.RemoteParam)
- local RemoteRequestValidator = {}
- RemoteRequestValidator.__index = RemoteRequestValidator
- function RemoteRequestValidator.New()
- return setmetatable({
- _RemoteParams = {}
- }, RemoteRequestValidator)
- end
- function RemoteRequestValidator:AddParam()
- local RemoteParamObj = RemoteParam.New()
- table.insert(self._RemoteParams, RemoteParamObj)
- return RemoteParamObj
- end
- function RemoteRequestValidator:Validate(...)
- local Params = {...}
- if (#Params ~= #self._RemoteParams) then
- return false
- end
- for Key, Param in ipairs(Params) do
- if (not self._RemoteParams[Key]:Validate(Param)) then
- return false
- end
- end
- return true
- end
- return RemoteRequestValidator
- --RemoteParam module:
- local RemoteParam = {}
- RemoteParam.__index = RemoteParam
- function RemoteParam.New()
- return setmetatable({}, RemoteParam)
- end
- function RemoteParam:SetSanityCallback(Callback)
- assert(typeof(Callback) == "function", "RemoteParam Callback must be a function")
- self._Callback = Callback
- end
- function RemoteParam:Validate(Value)
- return self._Callback(Value)
- end
- return RemoteParam
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement