| | | 1 | | // Copyright (c) 2020 .NET Foundation and Contributors. All rights reserved. |
| | | 2 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 3 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 4 | | // See the LICENSE file in the project root for full license information. |
| | | 5 | | |
| | | 6 | | using ReactiveUI.Validation.Collections; |
| | | 7 | | using ReactiveUI.Validation.Components.Abstractions; |
| | | 8 | | |
| | | 9 | | namespace ReactiveUI.Validation.States |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Represents the validation state of a validation component. |
| | | 13 | | /// </summary> |
| | | 14 | | public sealed class ValidationState |
| | | 15 | | { |
| | | 16 | | /// <summary> |
| | | 17 | | /// Initializes a new instance of the <see cref="ValidationState"/> class. |
| | | 18 | | /// </summary> |
| | | 19 | | /// <param name="isValid">Determines if the property is valid or not.</param> |
| | | 20 | | /// <param name="text">Validation text.</param> |
| | | 21 | | /// <param name="component">Validation property.</param> |
| | | 22 | | public ValidationState(bool isValid, string text, IValidationComponent component) |
| | 4 | 23 | | : this(isValid, new ValidationText(text), component) |
| | | 24 | | { |
| | 4 | 25 | | } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Initializes a new instance of the <see cref="ValidationState"/> class. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <param name="isValid">Determines if the property is valid or not.</param> |
| | | 31 | | /// <param name="text">Validation text.</param> |
| | | 32 | | /// <param name="component">Validation property.</param> |
| | 198 | 33 | | public ValidationState(bool isValid, ValidationText text, IValidationComponent component) |
| | | 34 | | { |
| | 198 | 35 | | IsValid = isValid; |
| | 198 | 36 | | Text = text ?? throw new System.ArgumentNullException(nameof(text)); |
| | 198 | 37 | | Component = component ?? throw new System.ArgumentNullException(nameof(component)); |
| | 198 | 38 | | } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Gets the associated component. |
| | | 42 | | /// </summary> |
| | 54 | 43 | | public IValidationComponent Component { get; } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Gets a value indicating whether the validation is currently valid or not. |
| | | 47 | | /// </summary> |
| | 276 | 48 | | public bool IsValid { get; } |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Gets the validation text. |
| | | 52 | | /// </summary> |
| | 234 | 53 | | public ValidationText Text { get; } |
| | | 54 | | } |
| | | 55 | | } |