ConstRule class final

Validates that a value is exactly equal to the schema-declared constant.

Corresponds to const in JSON Schema spec §6.1.3. The comparison uses DeepCollectionEquality so that nested List and Map values are compared by structural value rather than by reference. Primitive values (numbers, strings, booleans, null) are also handled correctly.

Unlike required, the const keyword validates the value of the instance — presence is enforced separately via required. A const: null schema accepts only the value null.

Inheritance

Constructors

ConstRule(dynamic constValue)
Creates a rule that accepts only constValue.
const

Properties

constValue → dynamic
The single accepted value.
final
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(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