FT.js
Runtime Type Check System For Javascript
Install
npm install ftjs
Type Definition Example ('./examples/System.ft')
#SimpleTypes String : /.?/ Integer : Global.Integer Int : Integer Boolean : Global.Boolean Bool : Boolean Double : Global.Double Numeric : Double | Integer Null : Global.Null Undefined : Global.Undefined Email : /^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i Strings : [String] #TypeExtensions String...Min min : /^.{#{min},}$/Max max : /^.{,#{max}}$/Range min max : /^.{#{min},#{max}}$/ Integer...Min min : @ >= minMax max : @ <= max #Enums Status : "active" | "inactive" Missing : Null | Undefined #ComplexTypes User------------email : Emailpicture : Stringfirstname : String Range(5,20)lastname : String Min(5) Max(20)status : Statusbio : String | Missingtags : [String]
Use
var types = ; var fs = ; var validate = ; var user = email: 'a.stegno@gmail.com' picture: 'http://some-website.com/picture.png' firstname: 'Andrey' lastname: 'Test' status: 'active' bio: 'Ho' tags: "user" ; ; //true