osyrisrblx / t

A Runtime Typechecker for Roblox
MIT License
210 stars 39 forks source link

. #103

Closed recanman closed 2 years ago

noahwillcrow commented 2 years ago

Can you share an example of when and why?

noahwillcrow commented 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.

noahwillcrow commented 2 years ago

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.

noahwillcrow commented 2 years ago

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.