Closed recanman closed 2 years ago
for better code readability
How is it more readable to wrap your custom function in something that just calls your callback? You still write your custom function. t.custom(isMyType)
, but it's just... weird to me to do that. It's not super readable like t.numberPositive
is.
Other runtime validation libraries have this already.
"would you jump off a bridge just because ..."
It still feels like just using isMyType
is way better than t.custom(isMyType)
. It ultimately doesn't offer anything but calling your callback.
That's literally the same thing as this:
local isInDataStore = function(val)
-- get datastore, then get data, then return true if it exists
end
And t
is not meant to do validation like isInDataStore
. t
is a type checking library. To quote the root README, t
is "A Runtime Type Checker for Roblox" -- not a wholesale validation library. So unless you're doing a type check, you're not using t
as intended.
Can you share an example of when and why?