BooleanSchema class final
Schema for validating boolean values.
- Inheritance
- Mixed-in types
- Annotations
-
- @immutable
Constructors
-
BooleanSchema({bool isNullable = false, bool isOptional = false, String? description, List<
Constraint< constraints = const [], List<bool> >Refinement< refinements = const []})bool> > -
const
Properties
- acceptsNull → bool
-
Whether
parse(null)andencode(null)should accept null without raising a non-nullable failure. Defaults to isNullable; subclasses with branch-level null policies (e.g. AnyOfSchema) override this hook.no setterinherited - baseFieldsHashCode → int
-
Computes hash code for base schema fields.
no setterinherited
-
constraints
→ List<
Constraint< bool> > -
Returns an unmodifiable view of the constraints for this schema.
no setterinherited
- description → String?
-
finalinherited
- hashCode → int
-
The hash code for this object.
no setteroverride
- isNullable → bool
-
finalinherited
- isOptional → bool
-
finalinherited
-
refinements
→ List<
Refinement< bool> > -
Returns an unmodifiable view of the refinements for this schema.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schemaType → SchemaType
-
The schema type category for this schema.
no setteroverride
- schemaTypeName → String
-
Human-readable type name for error messages and debugging.
no setterinherited
Methods
-
applyConstraintsAndRefinements(
bool value, SchemaContext context) → SchemaResult< bool> -
Applies constraints and refinements to a runtime value.
inherited
-
baseFieldsEqual(
AckSchema other) → bool -
Compares base schema fields for equality.
inherited
-
constrain(
Constraint< bool> constraint, {String? message}) → BooleanSchema -
Adds a raw
constraintto the schema.inherited -
copyWith(
{bool? isNullable, bool? isOptional, String? description, List< Constraint< ? constraints, List<bool> >Refinement< ? refinements}) → BooleanSchemabool> > -
Returns a copy of this schema with the given fields replaced.
override
-
describe(
String description) → BooleanSchema -
Sets the description for the schema.
inherited
-
encode(
bool? value, {String? debugName}) → bool? -
Encodes a runtime value to a boundary value, throwing on failure.
inherited
-
encodeAsBoundary(
bool value, SchemaContext context) → SchemaResult< bool> -
Helper for schemas whose boundary == runtime: validates the runtime
value and, if it passes, returns it as the boundary value unchanged.
Only safe to call when
BoundaryandRuntimeare the same type.inherited -
encodeWithContext(
bool value, SchemaContext context) → SchemaResult< bool> -
Encodes a runtime value into a boundary value. The base class strips
nullbefore calling this; subclasses receive a non-nullvalue.inherited -
failNonNullable(
SchemaContext context) → SchemaResult< bool> -
Runtime-side non-nullable failure.
inherited
-
failNonNullableEncode(
SchemaContext context) → SchemaResult< bool> -
Encode-side non-nullable failure.
inherited
-
handleNullInput(
Object? inputValue, SchemaContext context) → SchemaResult< bool> ? -
Centralized null gate for the parse/validate paths. Returns null when
inputValueis non-null; otherwise returns Ok(null) if acceptsNull is true or a non-nullable failure.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullable(
{bool value = true}) → BooleanSchema -
Marks the schema as nullable.
inherited
-
optional(
{bool value = true}) → BooleanSchema -
Marks the schema as optional so the field can be omitted from an object.
inherited
-
parse(
Object? value, {String? debugName}) → bool? -
Parses and validates a value, throwing an AckException if it fails.
inherited
-
parseAs<
TOut extends Object> (Object? value, TOut map(bool? validated), {String? debugName}) → TOut -
Parses and validates a value, then maps the validated value to
TOut.inherited -
parseWithContext(
Object? value, SchemaContext context) → SchemaResult< bool> -
Decodes a boundary value into a runtime value.
inherited
-
refine(
bool validate(bool value), {String message = 'The value did not pass the custom validation.'}) → BooleanSchema -
Adds a custom validation check that runs after all other validations.
inherited
-
safeEncode(
bool? value, {String? debugName}) → SchemaResult< bool> -
Encodes a runtime value to a boundary value, returning a SchemaResult.
inherited
-
safeParse(
Object? value, {String? debugName}) → SchemaResult< bool> -
Parses and validates a value, returning a SchemaResult.
inherited
-
safeParseAs<
TOut extends Object> (Object? value, TOut map(bool? validated), {String? debugName}) → SchemaResult< TOut> -
Parses and validates a value, then maps the validated value to
TOut.inherited -
toJsonSchema(
) → Map< String, Object?> -
Converts this schema to a JSON Schema Draft-7 representation.
inherited
-
toMap(
) → Map< String, Object?> -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validateRuntimeWithContext(
Object? value, SchemaContext context) → SchemaResult< bool> -
Validates that
valueis a valid runtime value for this schema.override -
withConstraint(
Constraint< bool> constraint) → BooleanSchema -
Adds a validation constraint to the schema.
inherited
-
withConstraints(
List< Constraint< newConstraints) → BooleanSchemabool> > -
Adds a list of validation constraints to the schema.
inherited
-
withDefault(
bool defaultValue) → DefaultSchema< bool, bool> -
Wraps this schema in a DefaultSchema that supplies
defaultValuewhen the parse input is null. Object encode also injects encoded defaults for missing default-wrapped fields.inherited -
withRuntimeConfig(
{bool? isNullable, bool? isOptional, String? description, List< Constraint< ? constraints, List<bool> >Refinement< ? refinements}) → BooleanSchemabool> > -
Returns a copy of this schema with runtime-side configuration replaced.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override