Skip to content

Commit acfcd8c

Browse files
committed
logo + readme update
1 parent 7e39190 commit acfcd8c

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

README.md

+47-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Form validation module
22

3-
![logo](https://github.com/rsamec/form/blob/master/form_logo.gif)
3+
![logo](https://github.com/rsamec/form/blob/master/form_logo.jpg)
44

5-
Validation module is a lightweight JavaScript library for easy business rules definition of the product, the contract or validation rules of the form.
5+
Validation module is a lightweight JavaScript library for easy business rules definition of the product, the contract, the form etc.
6+
7+
[API + tutorial] (https://github.com/rsamec/form/wiki)
68

79
## Installation
810

@@ -16,6 +18,7 @@ This module is installed via bower:
1618

1719
Add reference to dist/form.min.js file.
1820

21+
To create abstract validator
1922
``` js
2023
//create new validator for object with structure<IPerson>
2124
var personValidator = new Validation.AbstractValidator();
@@ -32,12 +35,52 @@ Add reference to dist/form.min.js file.
3235
personValidator.RuleFor("LastName", required);
3336
personValidator.RuleFor("LastName",maxLength);
3437

35-
personValidator = personValidator.CreateRule("Person");
38+
```
39+
40+
To create test data
41+
```js
42+
//create test data
43+
var data = {
44+
Person1:
45+
{
46+
FirstName:'John',
47+
LastName: 'Smith'
48+
},
49+
Person2:{}
50+
51+
}
52+
53+
//create concrete rule
54+
var person1Validator = personValidator.CreateRule("Person 1");
3655

37-
var result = this.PersonValidator.Validate(this.Data);
56+
//execute validation
57+
var result = person1Validator.Validate(this.Data.Person1);
58+
59+
//verify results
3860
if (result.HasErrors){
3961
console.log(result.ErrorMessage);
4062
}
63+
//---------
64+
//--outputs
65+
//---------
66+
67+
//create concrete rule
68+
var person2Validator = personValidator.CreateRule("Person 2");
69+
70+
//execute validation
71+
var result = person2Validator.Validate(this.Data.Person1);
72+
73+
//verify results
74+
if (result.HasErrors){
75+
console.log(result.ErrorMessage);
76+
}
77+
78+
//---------
79+
//--outputs
80+
//---------
81+
// FirstName: Field is required.
82+
// LastName: Field is required.
83+
4184
```
4285

4386
## Source code

form_logo.gif

-8.11 KB
Binary file not shown.

form_logo.jpg

12 KB
Loading

test/validation/rules.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
///<reference path='../../typings/node/node.d.ts'/>
33
///<reference path='../../typings/underscore/underscore.d.ts'/>
44

5-
var Validation = require('../../src/validation/validation.js');
5+
var Validation = require(' ../../src/validation/validation.js');
66
var expect = require('expect.js');
77
var _:UnderscoreStatic = require('underscore');
88
var Q = require('q');

0 commit comments

Comments
 (0)