OnlyOneExistsRule class
Validation rule that check that at exactly one of the object properties is not null.
See IValidationRule
Example
var schema = Schema()
.withRule( OnlyOneExistsRule('field1', 'field2'));
schema.validate({ field1: 1, field2: 'A' }); // Result: only one of properties field1, field2 must exist
schema.validate({ field1: 1 }); // Result: no errors
schema.validate({ }); // Result: only one of properties field1, field2 must exist
- Implemented types
Constructors
-
OnlyOneExistsRule(List<
String> properties) - Creates a new validation rule and sets its values
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
String? path, Schema schema, dynamic value, List< ValidationResult> results) → void -
Validates a given value against this rule.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited