jsigbiz / spec

JavaScript signature notation
131 stars 6 forks source link

Enum extension #9

Closed Raynos closed 9 years ago

Raynos commented 11 years ago

I have a thing called Enum in my validation library ( https://github.com/Colingo/valid-schema#enum )

Where you say

// type Foo := { foo: Enum("one", "two", "three") }

and it allows you to say that a certain key is a value from a list.

Example depends on my := extension and my type name := x => name : x and name := x => name x conventions

Raynos commented 9 years ago

This can be done as { foo: "one" | "two" | "three" }

Using type unions instead of an Enum primitive is fine.