-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented validation and started writing tests
- Loading branch information
Surdu Nicolae
committed
Apr 25, 2015
1 parent
79a3d84
commit 6edb20e
Showing
9 changed files
with
168 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module.exports = function(grunt) { | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON("package.json"), | ||
|
||
jasmine_nodejs: { | ||
options: { | ||
specNameSuffix: '-spec.js', | ||
}, | ||
|
||
dist: { | ||
specs:[ | ||
"specs/**-spec.js" | ||
] | ||
} | ||
}, | ||
|
||
watch: { | ||
files: ["src/**/*.js", "specs/**/*.js", "*.js"], | ||
tasks: "test", | ||
options: { | ||
debounceDelay: 1000, | ||
} | ||
} | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-jasmine-nodejs'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
|
||
grunt.registerTask("test", ["jasmine_nodejs"]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#Formless | ||
|
||
Documentation comming soon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
{ | ||
"name": "Formless", | ||
"version": "0.0.0", | ||
"description": "", | ||
"description": "Form handling solution for node.js", | ||
"main": "formless.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"start": "grunt watch", | ||
"test": "grunt test" | ||
}, | ||
"author": "", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Formless-js/formless" | ||
}, | ||
"author": "Surdu Nicolae", | ||
"license": "MIT", | ||
"dependencies": { | ||
"node.extend": "^1.1.3" | ||
}, | ||
"devDependencies": { | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"grunt-jasmine-nodejs": "^1.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = [ | ||
{ | ||
name: "firstName", | ||
type: "text", | ||
required: true | ||
}, | ||
|
||
{ | ||
name: "lastName", | ||
type: "text", | ||
required: true | ||
}, | ||
|
||
{ | ||
name: "nickname", | ||
type: "text", | ||
required: false | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var Form = require("../formless"); | ||
|
||
var basicForm = require("./assets/basicForm"); | ||
|
||
describe("form", function () { | ||
var form; | ||
|
||
beforeEach(function () { | ||
form = new Form(basicForm) | ||
}); | ||
|
||
it("should initialize with basic JSON", function () { | ||
expect(Object.keys(form.fields).length).toEqual(3); | ||
}); | ||
|
||
it("should validate required fields", function (done) { | ||
form.fill({ | ||
firstName: "Surdu", | ||
nickname: "nick" | ||
}); | ||
|
||
form.validate(function (err) { | ||
expect(err.lastName).not.toBeUndefined(); | ||
done(); | ||
}); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<div class="form-group{% if error %} has-error{% endif %}"> | ||
<div class="form-group{% if errors.length > 0 %} has-error{% endif %}"> | ||
<label class="control-label" for="{{name}}">{{label}}</label> | ||
<input type="text" | ||
class="form-control" | ||
id="{{name}}" | ||
name="{{name}}" | ||
value="{{value}}" | ||
{% if placeholder %}placeholder="{{placeholder}}"{% endif %} | ||
{% if required %}required{% endif %}> | ||
{% if error %} | ||
> <!-- {% if required %}required{% endif %} --> | ||
{% for error in errors %} | ||
<span class="help-block">{{error}}</span> | ||
{% endif%} | ||
{% endfor%} | ||
</div> |