Class ValidatableViewModelExtensions
- Namespace
- ReactiveUI.Validation.Extensions
- Assembly
- ReactiveUI.Validation.dll
Extensions methods associated to IValidatable
- Inheritance
-
Validatable
View Model Extensions
Methods
ClearValidationRules<TViewModel>(TViewModel)
Removes all validation rules associated with a view model.
public static void ClearValidationRules<TViewModel>(this TViewModel viewModel) where TViewModel : IReactiveObject, IValidatableViewModel
Parameters
viewModelTViewModel The view model to remove all validation rules from.
Type Parameters
TViewModelViewModel type.
Exceptions
- Argument
Null Exception Thrown when any argument is null.
ClearValidationRules<TViewModel, TViewModelProp>(TViewModel, Expression<Func<TViewModel, TViewModelProp>>)
Clears the validation rules associated with teh specified property.
public static void ClearValidationRules<TViewModel, TViewModelProp>(this TViewModel viewModel, Expression<Func<TViewModel, TViewModelProp>> viewModelProperty) where TViewModel : IReactiveObject, IValidatableViewModel
Parameters
viewModelTViewModel The view model to remove the validation rule from.
viewModelPropertyExpression<Func<TViewModel, TViewModelProp>>The property for which we are clearing the validation rules.
Type Parameters
TViewModelViewModel type.
TViewModelPropViewModel property type.
Exceptions
- Argument
Null Exception Thrown when any argument is null.
IsValid<TViewModel>(TViewModel)
Gets an observable for the validity of the ViewModel.
public static IObservable<bool> IsValid<TViewModel>(this TViewModel viewModel) where TViewModel : IReactiveObject, IValidatableViewModel
Parameters
viewModelTViewModel ViewModel instance.
Returns
- IObservable<bool>
Returns true if the ValidationContext is valid, otherwise false.
Type Parameters
TViewModelViewModel type.
ValidationRule<TViewModel>(TViewModel, IObservable<IValidationState>)
Setup a validation rule with a general observable based on IValidation
[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
Parameters
viewModelTViewModel ViewModel instance.
validationObservableIObservable<IValidationState >Observable to define if the viewModel is valid or not.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result in an inconsistent performance.
ValidationRule<TViewModel>(TViewModel, IObservable<bool>, string)
Setup a validation rule with a general observable indicating validity and a static error message.
[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
Parameters
viewModelTViewModel ViewModel instance.
validationObservableIObservable<bool>Observable to define if the viewModel is valid or not.
messagestringValidation error message.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result in an inconsistent performance.
ValidationRule<TViewModel, TValue>(TViewModel, IObservable<TValue>)
Setup a validation rule with a general observable based on IValidation
[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
Parameters
viewModelTViewModel ViewModel instance.
validationObservableIObservable<TValue>Observable to define if the viewModel is valid or not.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
TValueValidation observable type.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result in an inconsistent performance.
ValidationRule<TViewModel, TValue>(TViewModel, IObservable<TValue>, Func<TValue, bool>, Func<TValue, string>)
Setup a validation rule with a general observable indicating validity with a dynamic validation function and a dynamic context-aware error message.
[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
Parameters
viewModelTViewModel ViewModel instance.
validationObservableIObservable<TValue>Observable to define if the viewModel is valid or not.
isValidFuncFunc<TValue, bool>Func to define if the value emitted by the observable is valid.
messageFuncFunc<TValue, string>Func to define the validation error message based on the observable value.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
TValueValidation observable type.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result in an inconsistent performance.
ValidationRule<TViewModel, TViewModelProp>(TViewModel, Expression<Func<TViewModel, TViewModelProp?>>, Func<TViewModelProp?, bool>, Func<TViewModelProp?, string>)
Setup a validation rule for a specified ViewModel property with dynamic error message.
[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
Parameters
viewModelTViewModel ViewModel instance.
viewModelPropertyExpression<Func<TViewModel, TViewModelProp>>ViewModel property.
isPropertyValidFunc<TViewModelProp, bool>Func to define if the viewModelProperty is valid or not.
messageFunc<TViewModelProp, string>Func to define the validation error message based on the viewModelProperty value.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
TViewModelPropViewModel property type.
ValidationRule<TViewModel, TViewModelProp>(TViewModel, Expression<Func<TViewModel, TViewModelProp?>>, Func<TViewModelProp?, bool>, string)
Setup a validation rule for a specified ViewModel property with static error message.
[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
Parameters
viewModelTViewModel ViewModel instance.
viewModelPropertyExpression<Func<TViewModel, TViewModelProp>>ViewModel property.
isPropertyValidFunc<TViewModelProp, bool>Func to define if the viewModelProperty is valid or not.
messagestringValidation error message.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
TViewModelPropViewModel property type.
ValidationRule<TViewModel, TViewModelProp>(TViewModel, Expression<Func<TViewModel, TViewModelProp>>, IObservable<IValidationState>)
Setup a validation rule with a general observable based on IValidation
[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
Parameters
viewModelTViewModel ViewModel instance.
viewModelPropertyExpression<Func<TViewModel, TViewModelProp>>ViewModel property referenced in viewModelObservableProperty.
validationObservableIObservable<IValidationState >Observable to define if the viewModel is valid or not.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
TViewModelPropViewModel property type.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result in an inconsistent performance.
ValidationRule<TViewModel, TViewModelProp>(TViewModel, Expression<Func<TViewModel, TViewModelProp>>, IObservable<bool>, string)
Setup a validation rule with a general observable indicating validity and a static error message for the given view model property.
[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
Parameters
viewModelTViewModel ViewModel instance.
viewModelPropertyExpression<Func<TViewModel, TViewModelProp>>ViewModel property referenced in viewModelObservableProperty.
viewModelObservableIObservable<bool>Observable to define if the viewModel is valid or not.
messagestringValidation error message.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
TViewModelPropViewModel property type.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result in an inconsistent performance.
ValidationRule<TViewModel, TViewModelProp, TValue>(TViewModel, Expression<Func<TViewModel, TViewModelProp>>, IObservable<TValue>)
Setup a validation rule with a general observable based on IValidation
[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
Parameters
viewModelTViewModel ViewModel instance.
viewModelPropertyExpression<Func<TViewModel, TViewModelProp>>ViewModel property referenced in viewModelObservableProperty.
validationObservableIObservable<TValue>Observable to define if the viewModel is valid or not.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
TViewModelPropViewModel property type.
TValueValidation observable type.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result in an inconsistent performance.
ValidationRule<TViewModel, TViewModelProp, TValue>(TViewModel, Expression<Func<TViewModel, TViewModelProp>>, IObservable<TValue>, Func<TValue, bool>, Func<TValue, string>)
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.
[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
Parameters
viewModelTViewModel ViewModel instance.
viewModelPropertyExpression<Func<TViewModel, TViewModelProp>>ViewModel property referenced in viewModelObservableProperty.
viewModelObservableIObservable<TValue>Observable to define if the viewModel is valid or not.
isValidFuncFunc<TValue, bool>Func to define if the value emitted by the observable is valid.
messageFuncFunc<TValue, string>Func to define the validation error message based on the observable value.
Returns
- Validation
Helper Returns a Validation
Helper object.
Type Parameters
TViewModelViewModel type.
TViewModelPropViewModel property type.
TValueValidation observable type.
Remarks
It should be noted that the observable should provide an initial value, otherwise that can result in an inconsistent performance.