You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hint: () =><span className="form-error is-visible">Passwords should be equal.</span>
101
+
},
102
+
// Define API rule to show hint after API error response
103
+
api: {
104
+
// We don't need the rule here because we will call the 'showError' method by hand on API error
105
+
hint:value=> (
106
+
<button
107
+
className="form-error is-visible"
108
+
>
109
+
APIError on "{value}"value. Focus to hide.
110
+
</button>
111
+
)
101
112
}
102
113
});
103
114
```
@@ -165,30 +176,24 @@ Any valid props can easily be passed to ```Form```, such ```onSubmit``` and ```m
165
176
166
177
3.```hideError(name)``` - hides a corresponding component's error.
167
178
168
-
4.```validateAll()``` - validates all react-validation components. Returns a map (key: field name prop, value: non passed validation rule) of invalid fields. <strong>UPD: from 2.10.0 returns ```undefined```. TBD.</strong>
179
+
4.```validateAll()``` - validates all react-validation components. Returns a map (key: field name prop, value: `<Array>`non passed validation rules) of invalid fields.
169
180
170
181
171
182
```javascript
172
183
exportdefaultclassCommentextendsComponent {
173
-
handleSubmit(event) {
184
+
handleSubmit=(event)=> {
174
185
event.preventDefault();
175
186
176
187
// Emulate async API call
177
188
setTimeout(() => {
178
-
this.form.showError('username', value=>
179
-
<button
180
-
onClick={this.removeApiError.bind(this)}
181
-
className="form-error is-visible"
182
-
>
183
-
APIError on "{value}"value. Click to hide out.
184
-
</button>
185
-
);
189
+
// NOTE: 'api' should be defined on 'extend' step
190
+
this.form.showError('username', 'api');
186
191
}, 1000);
187
-
}
192
+
};
188
193
189
-
removeApiError() {
190
-
this.form.hideError("username");
191
-
}
194
+
removeApiError= () => {
195
+
this.form.hideError('username');
196
+
};
192
197
193
198
render() {
194
199
return<Validation.components.Form ref={c=> { this.form= c }} onSubmit={this.handleSubmit.bind(this)}>
0 commit comments