},System.Func{--1,System.Boolean},System.String)} },System.Func{--1,System.Boolean},System.Func{--1,System.String})} ,System.String)} ,System.Func{--1,System.Boolean},System.Func{--1,System.String})} )} )} },System.IObservable{System.Boolean},System.String)} },System.IObservable{--2},System.Func{--2,System.Boolean},System.Func{--2,System.String})} },System.IObservable{ReactiveUI.Validation.States.IValidationState})} },System.IObservable{--2})}
ValidatableViewModelExtensions.ValidationRule(TViewModel, Expression>, Func, string) method¶
Defined in
Type: ValidatableViewModelExtensions
Namespace: ReactiveUI.Validation.Extensions
Assembly: ReactiveUI.Validation.dll
Applies to
net10.0, net10.0-tvos26.0, net10.0-maccatalyst26.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net10.0-macos26.0, net10.0-windows10.0.19041, net10.0-ios26.0, net10.0-android36.0, net9.0, net9.0-windows10.0.19041, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-macos14.2, net8.0-maccatalyst17.5, net8.0-ios17.5, net8.0-tvos17.2, net8.0-windows10.0.19041, net8.0-macos14.5, netstandard2.1, net481, net462, net471
Overloads¶
- 1.
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp?>> viewModelProperty, Func<TViewModelProp?, bool> isPropertyValid, string message) where TViewModel : IReactiveObject, IValidatableViewModel - 2.
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp?>> viewModelProperty, Func<TViewModelProp?, bool> isPropertyValid, Func<TViewModelProp?, string> message) where TViewModel : IReactiveObject, IValidatableViewModel - 3.
public static ValidationHelper ValidationRule<TViewModel>(this TViewModel viewModel, IObservable<bool> validationObservable, string message) where TViewModel : IReactiveObject, IValidatableViewModel - 4.
public static ValidationHelper ValidationRule<TViewModel, TValue>(this TViewModel viewModel, IObservable<TValue> validationObservable, Func<TValue, bool> isValidFunc, Func<TValue, string> messageFunc) where TViewModel : IReactiveObject, IValidatableViewModel - 5.
public static ValidationHelper ValidationRule<TViewModel>(this TViewModel viewModel, IObservable<IValidationState> validationObservable) where TViewModel : IReactiveObject, IValidatableViewModel - 6.
public static ValidationHelper ValidationRule<TViewModel, TValue>(this TViewModel viewModel, IObservable<TValue> validationObservable) where TViewModel : IReactiveObject, IValidatableViewModel where TValue : IValidationState - 7.
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp>> viewModelProperty, IObservable<bool> viewModelObservable, string message) where TViewModel : IReactiveObject, IValidatableViewModel - 8.
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp, TValue>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp>> viewModelProperty, IObservable<TValue> viewModelObservable, Func<TValue, bool> isValidFunc, Func<TValue, string> messageFunc) where TViewModel : IReactiveObject, IValidatableViewModel - 9.
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp>> viewModelProperty, IObservable<IValidationState> validationObservable) where TViewModel : IReactiveObject, IValidatableViewModel - 10.
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp, TValue>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp>> viewModelProperty, IObservable<TValue> validationObservable) where TViewModel : IReactiveObject, IValidatableViewModel where TValue : IValidationState
1. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp?>> viewModelProperty, Func<TViewModelProp?, bool> isPropertyValid, string message) where TViewModel : IReactiveObject, IValidatableViewModel
Summary: Setup a validation rule for a specified ViewModel property with static error message.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
TViewModelProp | ViewModel property type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
viewModelProperty | Expression | ViewModel property. |
isPropertyValid | Func | Func to define if the viewModelProperty is valid or not. |
message | string | Validation error message. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel, viewModelProperty, isPropertyValid, or message is null or empty. |
2. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp?>> viewModelProperty, Func<TViewModelProp?, bool> isPropertyValid, Func<TViewModelProp?, string> message) where TViewModel : IReactiveObject, IValidatableViewModel
Summary: Setup a validation rule for a specified ViewModel property with dynamic error message.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
TViewModelProp | ViewModel property type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
viewModelProperty | Expression | ViewModel property. |
isPropertyValid | Func | Func to define if the viewModelProperty is valid or not. |
message | Func | Func to define the validation error message based on the viewModelProperty value. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel, viewModelProperty, isPropertyValid, or message is null. |
3. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel>(this TViewModel viewModel, IObservable<bool> validationObservable, string message) where TViewModel : IReactiveObject, IValidatableViewModel
Summary: Setup a validation rule with a general observable indicating validity and a static error message.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
validationObservable | IObservable | Observable to define if the viewModel is valid or not. |
message | string | Validation error message. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result
in an inconsistent performance.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel, validationObservable, or message is null. |
4. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel, TValue>(this TViewModel viewModel, IObservable<TValue> validationObservable, Func<TValue, bool> isValidFunc, Func<TValue, string> messageFunc) where TViewModel : IReactiveObject, IValidatableViewModel
Summary: Setup a validation rule with a general observable indicating validity with a dynamic validation function and a dynamic context-aware error message.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
TValue | Validation observable type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
validationObservable | IObservable | Observable to define if the viewModel is valid or not. |
isValidFunc | Func | Func to define if the value emitted by the observable is valid. |
messageFunc | Func | Func to define the validation error message based on the observable value. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result
in an inconsistent performance.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel, validationObservable, isValidFunc, or messageFunc is null. |
5. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel>(this TViewModel viewModel, IObservable<IValidationState> validationObservable) where TViewModel : IReactiveObject, IValidatableViewModel
Summary: Setup a validation rule with a general observable based on IValidationState.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
validationObservable | IObservable | Observable to define if the viewModel is valid or not. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result
in an inconsistent performance.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel or validationObservable is null. |
6. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel, TValue>(this TViewModel viewModel, IObservable<TValue> validationObservable) where TViewModel : IReactiveObject, IValidatableViewModel where TValue : IValidationState
Summary: Setup a validation rule with a general observable based on IValidationState.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
TValue | Validation observable type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
validationObservable | IObservable | Observable to define if the viewModel is valid or not. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result
in an inconsistent performance.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel or validationObservable is null. |
7. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp>> viewModelProperty, IObservable<bool> viewModelObservable, string message) where TViewModel : IReactiveObject, IValidatableViewModel
Summary: Setup a validation rule with a general observable indicating validity and a static error message for the given view model property.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
TViewModelProp | ViewModel property type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
viewModelProperty | Expression | ViewModel property referenced in viewModelObservableProperty. |
viewModelObservable | IObservable | Observable to define if the viewModel is valid or not. |
message | string | Validation error message. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result
in an inconsistent performance.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel, viewModelProperty, viewModelObservable, or message is null. |
8. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp, TValue>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp>> viewModelProperty, IObservable<TValue> viewModelObservable, Func<TValue, bool> isValidFunc, Func<TValue, string> messageFunc) where TViewModel : IReactiveObject, IValidatableViewModel
Summary: Setup a validation rule with a general observable indicating validity with a dynamic validation function and a dynamic context-aware error message for the given view model property.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
TViewModelProp | ViewModel property type. |
TValue | Validation observable type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
viewModelProperty | Expression | ViewModel property referenced in viewModelObservableProperty. |
viewModelObservable | IObservable | Observable to define if the viewModel is valid or not. |
isValidFunc | Func | Func to define if the value emitted by the observable is valid. |
messageFunc | Func | Func to define the validation error message based on the observable value. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result
in an inconsistent performance.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel, viewModelProperty, viewModelObservable, isValidFunc, or messageFunc is null. |
9. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp>> viewModelProperty, IObservable<IValidationState> validationObservable) where TViewModel : IReactiveObject, IValidatableViewModel
Summary: Setup a validation rule with a general observable based on IValidationState.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
TViewModelProp | ViewModel property type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
viewModelProperty | Expression | ViewModel property referenced in viewModelObservableProperty. |
validationObservable | IObservable | Observable to define if the viewModel is valid or not. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result
in an inconsistent performance.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel, viewModelProperty, or validationObservable is null. |
10. Overload¶
Attributes: [RequiresDynamicCode("WhenAnyValue uses expression trees which require dynamic code generation in AOT scenarios.")] [RequiresUnreferencedCode("WhenAnyValue may reference members that could be trimmed in AOT scenarios.")]
public static ValidationHelper ValidationRule<TViewModel, TViewModelProp, TValue>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp>> viewModelProperty, IObservable<TValue> validationObservable) where TViewModel : IReactiveObject, IValidatableViewModel where TValue : IValidationState
Summary: Setup a validation rule with a general observable based on IValidationState.
Type parameters
| Name | Description |
|---|---|
TViewModel | ViewModel type. |
TViewModelProp | ViewModel property type. |
TValue | Validation observable type. |
Parameters
| Name | Type | Description |
|---|---|---|
viewModel | TViewModel | ViewModel instance. |
viewModelProperty | Expression | ViewModel property referenced in viewModelObservableProperty. |
validationObservable | IObservable | Observable to define if the viewModel is valid or not. |
Returns: ValidationHelper -- Returns a ValidationHelper object.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result
in an inconsistent performance.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when viewModel, viewModelProperty, or validationObservable is null. |