New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dui-active-record

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dui-active-record - npm Package Compare versions

Comparing version 0.1.1 to 0.2.1

example/index.d.ts

2

package.json
{
"name": "dui-active-record",
"version": "0.1.1",
"version": "0.2.1",
"description": "Active Record parrent implementation on typescript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

# dui-active-record
ActiveRecord pattern implementation
Works on Node.js and on browsers
Works on Node.js and on browsers, without any dependecies
## Functional style initialization ##
### Functional style Validation ###
```typescript
interface IFoo {
bar: number;
}
```
let FooValidator = new ModelValidator({
allowUnsafe: false,
strict : true,
rules : {
bar: ['int'],
},
});
### Validation ###
```typescript
let FooValidator = new ModelValidator(
[
{
field : 'bar',
validators: ['int'],
},
],
);
// single using
let foo = {
bar: 123,
bar : '123',
other: 'abc',
};
FooValidator.validate(foo) : boolean;
FooValidator.errors(foo) : Error[];
FooValidator.validate(foo);
// return false
// using with array
FooValidator.allErrors(foo);
// return [
// new ValidationError(
// 'int',
// 'Value must be a integer',
// undefined,
// 'bar',
// ),
// new ValidationError(
// 'unsafe',
// 'Unsafe attributes is not allowed',
// undefined,
// 'other',
// ),
// ]
let foos: IFoo[] = [
// 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 ###
```typescript
let foos = [
{

@@ -44,2 +72,3 @@ bar: 5,

foos.map(FooValidator.validate);
foos.map(FooValidator.allErrors);
foos.map(FooValidator.errors);

@@ -46,0 +75,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc