ContainsRule class final

Validates that an array contains at least minContains (default 1) and at most maxContains (optional) elements that satisfy itemSchema.

Corresponds to the contains, minContains, and maxContains keywords in JSON Schema spec §6.4.5, §6.4.4, and §6.4.6. The three keywords are tightly coupled and implemented together in this rule.

Sub-schema violations are used only as a counting signal — they are never emitted to the caller. The rule reports a single violation when the count falls outside the permitted range.

Non-array instances are silently skipped (no violation).

minContains: 0 makes the rule effectively optional unless maxContains is set and exceeded.

Inheritance

Constructors

ContainsRule({required SchemaRule itemSchema, int minContains = 1, int? maxContains})
Creates a rule enforcing that minContains to maxContains elements satisfy itemSchema.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
itemSchema SchemaRule
The sub-schema that each candidate element is tested against.
final
maxContains int?
The maximum number of elements allowed to satisfy itemSchema.
final
minContains int
The minimum number of elements that must satisfy itemSchema.
final
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(dynamic value, String path) List<SchemaViolation>
Validates value at path and returns every violation found.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited