Skip to content

Commit d9c51ea

Browse files
committed
Update docs for v1
1 parent 5f0eec7 commit d9c51ea

File tree

2 files changed

+46
-34
lines changed

2 files changed

+46
-34
lines changed

README.md

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
A data modeling tool for NodeJS. It's 100% database agnostic, and 100% customizable.
99

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+
1013
# How to install
1114
Use NPM to install the package:
1215
```
@@ -45,7 +48,19 @@ var data = {
4548
age: 17 // Age does not match with min value
4649
};
4750

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+
*/
4964
```
5065

5166
# Modifiers
@@ -55,12 +70,7 @@ Modifiers are just functions. It will be executed for each property, and return
5570

5671
## Default
5772
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+
6474
```javascript
6575
{
6676
default: 'Default value'
@@ -237,40 +247,18 @@ This will validate `asd` but not `sdf`
237247
238248
# Tests
239249
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.
241251
242-
To run tests, just execute:
252+
First time you run tests, you might need to install Jasmine, and other dependencies. Just execute:
243253
```
244-
npm test
254+
npm install
245255
```
246256
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:
248258
```
249-
npm install
259+
npm test
250260
```
251261
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-
274262
275263
# Contribute
276264
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.

migration.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Migration Guide
2+
3+
## Breaking changes in v1.0!
4+
If you have been using this package in versions under 0.x, you have to update your code.
5+
6+
The major change in v1 is the way to display modelated data and errors. Now, its an object with both properties.
7+
8+
So, just update the calls to modelate:
9+
```
10+
var Modelate = require('modelate');
11+
12+
var model = { ... };
13+
var user = Modelate('User').model(model);
14+
15+
var result = user.modelate(data);
16+
17+
```
18+
to
19+
```
20+
var result = user.modelate(data).data;
21+
22+
```
23+
24+
And everything will work as it used to.

0 commit comments

Comments
 (0)