Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Golem

A collection of composable type validators that help enforce runtime type safety.


Golem is the combination of t and Guard


Simple Example

-- The value need to be typed manually for Golem.Struct (waiting for new type-solver)
local check = Golem.Check(Golem.Struct({
  test = Golem.String :: string,
  instance = Golem.InstanceOf("Workspace") :: Workspace
}))

check({
  test = "a",
  instance = workspace
}) -- will pass

Error Example

local check = Golem.Check(Golem.Struct({
  test = Golem.String :: string,
  instance = Golem.InstanceOf("Workspace") :: Workspace
}))

-- Since `game` is not `workspace`, the following check with error.
check({
  test = "a",
  instance = game
})

Advanced Example

local safeCheck = Golem.SafeCheck(Golem.Tuple(
  Golem.Optional(Golem.String),
  Golem.Or(Golem.String, Golem.Number)
))

local ok, errorMessage = safeCheck(nil, 10)
print(ok, errorMessage) -- Will print (true, nil)

local ok, errorMessage = safeCheck(nil, true)
print(ok, errorMessage) -- Will print (false, "Excepted string, got boolean OR Excepted number, got boolean")

About

A collection of composable type validators that help enforce runtime type safety.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages