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
Copy file name to clipboardexpand all lines: README.md
+21-10
Original file line number
Diff line number
Diff line change
@@ -221,15 +221,9 @@ this.ValidationRule(
221
221
"Passwords must match.");
222
222
```
223
223
224
-
## Capabilities
224
+
## Custom Formatters
225
225
226
-
In essence, ReactiveUI.Validation is a relatively simple model of the `ValidationContext` containing a list of `IValidationComponent` instances. An `IValidationComponent` provides an observable of `IValidationState`. Whenever validation state changes (either a transition of validity) or `ValidationText` changes, then a new value is pushed out.
227
-
228
-
1. Rules can be composed of single or multiple properties along with more generic Observables.
229
-
2. Validation text can encapsulate both valid and invalid states.
230
-
3. Binding can occur to either a View or an action.
231
-
4. Validation text can reference either the ViewModel or properties which comprise the validation rule e.g. include text entered as part of validation message.
232
-
5. Validation text output can be adjusted using custom formatters, not only allowing for single & multiline output but also for platforms like Android it should be possible to achieve richer renderings i.e. Bold/italics.
226
+
You can pass an instance of `IValidationTextFormatter<T>` to a call to `BindValidation` if you'd like to override the default `SingleLineFormatter` used in the validation library. The `SingleLineFormatter` accepts a separator char and uses whitespace by default, so the code snippet below shows how to use a non-default separator char:
233
227
234
228
```cs
235
229
// This formatter is based on the default SingleLineFormatter but uses a custom separator char.
@@ -238,7 +232,7 @@ this.BindValidation(ViewModel, x => x.ErrorLabel.Text, formatter)
238
232
.DisposeWith(disposables);
239
233
```
240
234
241
-
The simplest possible `IValidationTextFormatter<TOut>` implementation may look like this one.
235
+
The simplest possible custom `IValidationTextFormatter<TOut>` implementation may look like this one.
If you'd like to override the `IValidationTextFormatter<string>` used in ReactiveUI.Validation by default, register an instance of `IValidationTextFormatter<string>` into `Locator.CurrentMutable` before your app starts. This could be useful in cases when your app needs localization and you wish to pass message keys instead of messages to `ValidationRule` calls.
254
+
255
+
```cs
256
+
// Register a singleton instance of IValidationTextFormatter<string> into Splat.Locator.
In essence, ReactiveUI.Validation is a relatively simple model of the `ValidationContext` containing a list of `IValidationComponent` instances. An `IValidationComponent` provides an observable of `IValidationState`. Whenever validation state changes (either a transition of validity) or `ValidationText` changes, then a new value is pushed out.
263
+
264
+
1. Rules can be composed of single or multiple properties along with more generic Observables.
265
+
2. Validation text can encapsulate both valid and invalid states.
266
+
3. Binding can occur to either a View or an action.
267
+
4. Validation text can reference either the ViewModel or properties which comprise the validation rule e.g. include text entered as part of validation message.
268
+
5. Validation text output can be adjusted using custom formatters, not only allowing for single & multiline output but also for platforms like Android it should be possible to achieve richer renderings i.e. Bold/italics.
269
+
259
270
## Feedback
260
271
261
272
Please use [GitHub issues](https://github.com/reactiveui/ReactiveUI.Validation/issues) for questions, comments, or bug reports.
0 commit comments