Skip to content

Commit 91b86bb

Browse files
author
Vlad Balin
committed
Update databinding.md
1 parent e050d83 commit 91b86bb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

example/databinding.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,15 @@ Standard `<input>` will work. You may implement custom input controls to handle
153153
with validation and appearance.
154154

155155
```javascript
156-
const Input = ({ valueLink, ...props }) => (
156+
const Input = ({ valueLink, className, ...props }) => (
157157
<div className='wrapping'
158-
<input {...props} value={ valueLink.value } onChange={ e => valueLink.set( e.target.value ) }/>
158+
<input className={ className + ( valieLink.error ? ' error' : '' ) } {...props} value={ valueLink.value } onChange={ e => valueLink.set( e.target.value ) }/>
159159
</div>
160160
);
161161
```
162162

163+
Errors are attached to the links automatically, when model validation is failed. Validation checks can be attached to model attributes with `.has.check` specification. `x : Number.has.check( x => x > 0 )`, `y : Number.has.check( x => x < 0, 'y should be negative' )`.
164+
163165
### Binding to model attributes
164166

165167
```javascript

0 commit comments

Comments
 (0)