You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-34Lines changed: 22 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,9 @@
7
7
8
8
A data modeling tool for NodeJS. It's 100% database agnostic, and 100% customizable.
9
9
10
+
# Warning! Breaking changes in v1.0!
11
+
If you have been using this package in versions under 1.0.0, you have to update your code. [Follow the migration guide](migration.md) to use the v1.x library.
12
+
10
13
# How to install
11
14
Use NPM to install the package:
12
15
```
@@ -45,7 +48,19 @@ var data = {
45
48
age:17// Age does not match with min value
46
49
};
47
50
48
-
var result =user.modelate(data); // => { name: 'Paco }
51
+
var result =user.modelate(data);
52
+
/* Result:
53
+
{ data: {
54
+
name: 'Paco
55
+
},
56
+
error: [{
57
+
model: 'User',
58
+
field: 'age',
59
+
validator: 'value',
60
+
constrains: { max: 95, min: 18 }
61
+
}]
62
+
}
63
+
*/
49
64
```
50
65
51
66
# Modifiers
@@ -55,12 +70,7 @@ Modifiers are just functions. It will be executed for each property, and return
55
70
56
71
## Default
57
72
If there are not data for that property, it will create a given default value:
58
-
```javascript
59
-
{
60
-
default:String// Check if data has a JS type
61
-
}
62
-
```
63
-
For example:
73
+
64
74
```javascript
65
75
{
66
76
default:'Default value'
@@ -237,40 +247,18 @@ This will validate `asd` but not `sdf`
237
247
238
248
# Tests
239
249
240
-
I'm currently adding tests to this code. I'm using Jasmine, and saving tests in `/spec` folder.
250
+
Are built with Jasmine, and stored in `/spec` folder.
241
251
242
-
To run tests, just execute:
252
+
First time you run tests, you might need to install Jasmine, and other dependencies. Just execute:
243
253
```
244
-
npm test
254
+
npm install
245
255
```
246
256
247
-
First time you run tests, you might need to install Jasmine, and other possible test dependencies. To do it fastly, just execute:
257
+
To run tests, just execute:
248
258
```
249
-
npm install
259
+
npm test
250
260
```
251
261
252
-
And now you can run tests ^^
253
-
254
-
## Test coverage:
255
-
Master version might not have the last test updates. Check out the `develop` branch to see the last updates. Also, the actual test coverage (in `develop` branch) is fully referenced in #3 issue.
256
-
257
-
- [x] Core
258
-
- [x] Exported module
259
-
- [x] Model
260
-
- [x] Modelate
261
-
- [x] Validate
262
-
- [ ] Validators
263
-
- [x] Type
264
-
- [x] Length
265
-
- [x] Value
266
-
- [x] Custom function
267
-
- [x] Date
268
-
- [x] Regex
269
-
- [x] Email
270
-
- [ ] Model (Need help with this #15)
271
-
- [x] Modifiers
272
-
- [x] Default
273
-
274
262
275
263
# Contribute
276
264
You can use this code as you like. If you find a bug, or want to ask for a feature, just open an issue, and we'll do our best. If you can fix it, do a pull request to dev branch, and we promise to review it as fast as possible to merge it.
0 commit comments