Skip to content

Commit

Permalink
✏️ docs
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed May 10, 2016
1 parent 4940592 commit 3bb625f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 36 deletions.
34 changes: 17 additions & 17 deletions docs/fields/README.md → docs/fields/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ onValidated | `Function` | Event if validation executed. `onValidated(model, e
## Example

```js
{
type: "text",
label: "Name",
model: "name",
readonly: false,
featured: true,
disabled: false,
required: true,
default: "Anonymous",
validator: validators.string,
{
type: "text",
label: "Name",
model: "name",
readonly: false,
featured: true,
disabled: false,
required: true,
default: "Anonymous",
validator: validators.string,

onChanged(model, newVal, oldVal, field) {
console.log(`Model's name changed from ${oldVal} to ${newVal}. Model:`, model);
},
onChanged(model, newVal, oldVal, field) {
console.log(`Model's name changed from ${oldVal} to ${newVal}. Model:`, model);
},

onValidated(model, errors, field) {
if (errors.length > 0)
console.warn("Validation error in Name field! Errors:", errors);
}
onValidated(model, errors, field) {
if (errors.length > 0)
console.warn("Validation error in Name field! Errors:", errors);
}
}
```
43 changes: 25 additions & 18 deletions docs/fields/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,31 @@ min | `Number` | Minimum length of text (need `validators.string`)
max | `Number` | Maximum length of text (need `validators.string`)

## Usage
A featured and required name input field, where the length of name must be between 3 and 50 characters

```js
{
type: "text",
label: "Name",
model: "name",
min: 3,
max: 50,
required: true,
placeholder: "User's full name",

onChanged(model, newVal, oldVal, field) {
console.log(`Model's name changed from ${oldVal} to ${newVal}. Model:`, model);
},

onValidated(model, errors, field) {
if (errors.length > 0)
console.warn("Validation error in Name field! Errors:", errors);
}
}
{
type: "text",
label: "Name",
model: "name",
featured: true,
min: 3,
max: 50,
required: true,
placeholder: "User's full name",
validator: validators.string
}
```
Test field for website address with url validators
```js
{
type: "text",
label: "Website",
model: "web",
max: 255,
validator: [
validators.string
validators.url
]
}
```
2 changes: 1 addition & 1 deletion docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ The schema contains the fields of the form
}
```

[Available field types](fields/README.md)
[Available field types](fields/index.md)

0 comments on commit 3bb625f

Please sign in to comment.