Skip to content
This repository was archived by the owner on Sep 16, 2022. It is now read-only.

Commit dd70d80

Browse files
kevmooferhatb
authored andcommitted
Deprecate top-level VALID, INVALID, PENDING fields
Closes #298 Moved to AbstractControl class Now Control authors (and others) can access these without importing an implementation library ...and we don’t have to add 3 weird consts to one of our libraries ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=149728625
1 parent 4b0c013 commit dd70d80

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

lib/src/common/forms/model.dart

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ import "directives/validators.dart" show ValidatorFn, AsyncValidatorFn;
66

77
/// Indicates that a Control is valid, i.e. that no errors exist in the input
88
/// value.
9-
const VALID = "VALID";
9+
@Deprecated('Use AbstractControl.VALID instead.')
10+
const VALID = AbstractControl.VALID;
1011

1112
/// Indicates that a Control is invalid, i.e. that an error exists in the input
1213
/// value.
13-
const INVALID = "INVALID";
14+
@Deprecated('Use AbstractControl.INVALID instead.')
15+
const INVALID = AbstractControl.INVALID;
1416

1517
/// Indicates that a Control is pending, i.e. that async validation is occurring
1618
/// and errors are not yet available for the input value.
17-
const PENDING = "PENDING";
19+
@Deprecated('Use AbstractControl.VALID instead.')
20+
const PENDING = AbstractControl.PENDING;
21+
1822
bool isControl(Object control) => control is AbstractControl;
1923

2024
AbstractControl _find(AbstractControl control,
@@ -41,6 +45,18 @@ Stream<dynamic> _toStream(futureOrStream) {
4145
}
4246

4347
abstract class AbstractControl {
48+
/// Indicates that a Control is valid, i.e. that no errors exist in the input
49+
/// value.
50+
static const VALID = "VALID";
51+
52+
/// Indicates that a Control is invalid, i.e. that an error exists in the
53+
/// input value.
54+
static const INVALID = "INVALID";
55+
56+
/// Indicates that a Control is pending, i.e. that async validation is
57+
/// occurring and errors are not yet available for the input value.
58+
static const PENDING = "PENDING";
59+
4460
ValidatorFn validator;
4561
AsyncValidatorFn asyncValidator;
4662
dynamic _value;
@@ -55,6 +71,9 @@ abstract class AbstractControl {
5571
AbstractControl(this.validator, this.asyncValidator);
5672
dynamic get value => _value;
5773

74+
/// The validation status of the control.
75+
///
76+
/// One of [VALID], [INVALID], or [PENDING].
5877
String get status => _status;
5978

6079
bool get valid => identical(_status, VALID);

0 commit comments

Comments
 (0)