Skip to content

Repository files navigation

A simple schema/attributes library built on top of modern JavaScript

Structure provides a simple interface which allows you to add attributes to your classes based on a schema, with validations and type coercion.

Packages

Example Structure usage

For each attribute on your schema, a getter and a setter will be created into the given class. It'll also auto-assign those attributes passed to the constructor.

const{ attributes }=require('structure');constUser=attributes({name: String,age: {type: Number,default: 18,},birthday: Date,})(classUser{greet(){return`Hello ${this.name}`;}});constuser=newUser({name: 'John Foo',});user.name;// 'John Foo'user.greet();// 'Hello John Foo'

About

A simple schema/attributes library built on top of modern JavaScript

Topics

Resources

Contributing

Stars

301 stars

Watchers

11 watching

Forks

Releases

Packages

Used by

Contributors

Languages