dui-active-record
Implementation of the Active Record pattern for typescript
Works on Node.js and on browsers, with minimal dependecies
Functional style Validation
; ; FooValidator.validatefoo;// return false FooValidator.allErrorsfoo;// return [// new ValidationError(// 'int',// 'Value must be a integer',// undefined,// 'bar',// ),// new ValidationError(// 'unsafe',// 'Unsafe attributes is not allowed',// undefined,// 'other',// ),// ] // FooValidator.errors(foo)// {// bar : [// new ValidationError(// 'int',// 'Value must be a integer',// undefined,// 'bar',// ),// ],// other: [// new ValidationError(// 'unsafe',// 'Unsafe attributes is not allowed',// undefined,// 'other',// ),// ],};
Using for array
foos.mapFooValidator.validate;foos.mapFooValidator.allErrors;foos.mapFooValidator.errors;
Storage
;or; // single using; FooStorage.savefoo;FooStorage.save'someId', foo; // array using foos.mapFooStorage.save;
Class style initialization