validatable-record
Immutable.js Record powered with validate.js
Table of Contents
Install
$ npm install --save validatable-record
Usage
ValidatableRecord returns Record
in Immutable.js for extending your own class. Usage is almost the same as Record
in Immutable.js, but it has the power of validate.js
. With ValidatableRecord, you can define models with built-in validation logic.
const ManRecord = ; ... const man = name: "Justine"; age: 25; man // == true // Of course you can use `Immutable.Record` methodsmansize // 2man // "Justine"man // 25 const agelessMan = name: "Michael"; agelessMan // == false agelessMan // == [ "Age is invalid" ] // You can set your own error to modelagelessMan agelessMan // = [ "Unknown error" ]
Test
$ npm test
Contribute
PRs accepted.
License
The gem is available as open source under the terms of the MIT License.