StringSchema class final
Matches JSON strings, with optional length/pattern constraints.
Constructors
- StringSchema({int? minLength, int? maxLength, String? patternSource, String? format})
Properties
- defaultValue → Object?
-
The default supplied when providesDefault is true.
no setterinherited
- format → String?
-
JSON Schema
formathint (e.g.email), set by email.final - hashCode → int
-
The hash code for this object.
no setterinherited
- isOptional → bool
-
Whether an object field using this schema may be omitted entirely.
no setterinherited
- maxLength → int?
-
final
- minLength → int?
-
final
- patternSource → String?
-
final
- providesDefault → bool
-
Whether this schema supplies a default when the value is missing.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
describe(
String description) → Schema< String> -
Attaches a description, included in toJsonSchema. Descriptions are
the main way to tell an LLM what a field means — use them liberally.
inherited
-
email(
) → StringSchema - Requires a plausible email address.
-
max(
int length) → StringSchema -
Requires at most
lengthcharacters. -
min(
int length) → StringSchema -
Requires at least
lengthcharacters. -
nonEmpty(
) → StringSchema - Requires a non-empty string.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullable(
) → Schema< String?> -
Accepts
nullin addition to values matching this schema.inherited -
optional(
) → Schema< String> -
Marks an object field as omittable. When the key is absent the field
is left out of the resulting map (no error is reported).
inherited
-
parse(
Object? input) → String -
Validates a decoded JSON value, throwing SchemaValidationException
on failure.
inherited
-
parseText(
String text) → String -
Extracts JSON from raw LLM
textand validates it, throwing SchemaValidationException on failure.inherited -
pattern(
String source) → StringSchema -
Requires the string to match
source(a regular expression). -
refine(
bool predicate(String value), {String? message}) → Schema< String> -
Adds a custom check on the validated value.
inherited
-
safeParse(
Object? input) → SchemaResult< String> -
Validates a decoded JSON value. Never throws; returns a
SchemaSuccess or a SchemaFailure carrying every issue found.
inherited
-
safeParseText(
String text) → SchemaResult< String> -
Extracts JSON from raw LLM
textand validates it. Never throws.inherited -
toJsonSchema(
) → Map< String, Object?> -
This schema expressed as a JSON Schema map, suitable for LLM
tool-parameter definitions and structured-output APIs.
override
-
toJsonSchemaString(
{bool pretty = false}) → String -
toJsonSchema encoded as a JSON string.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transform<
R> (R mapper(String value)) → Schema< R> -
Maps the validated value with
mapper. Exceptions thrown bymapperare converted into validation issues.inherited -
validateAt(
Object? input, List< Object> path) → SchemaResult<String> -
Validates
inputlocated atpathwithin a larger document.override -
withDefault(
String value) → Schema< String> -
Uses
valuewhen the input isnullor the object key is absent.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited