minted library

Well-modelled value types (domain primitives) for entities usually left as a raw String: email, IBAN, and more.

Every type is built on "parse, don't validate": build it through tryParse (returns null on invalid input) or parse (throws a MintedFormatException), never a public constructor, so any instance that exists is guaranteed well-formed.

Classes

Date
A calendar date: a year, month, and day, with no time-of-day and no time zone.
DateDayOutOfRange
The day falls outside 1-maxDay. The bound is leap-year aware, so 29 February is out of range in a common year and in range in a leap one.
DateFailure
Why a Date refused its input. Sealed, not an enum, because the variants report the offending number back. Two remedies: DateNotIso8601 means fix the format, the rest mean fix a number.
DateMonthOutOfRange
The month falls outside 1-12.
DateNotIso8601
The text is not the ISO 8601 YYYY-MM-DD shape.
DateYearOutOfRange
The year falls outside 0000-9999, the range a Date can hold.
Digits
An immutable, iterable sequence of decimal digits, each a Digit (0-9).
IbanChecksumFailed
The mod-97 check digits disagree with the rest of the number: a character is mistyped.
IbanFailure
Why an Iban refused its input. Sealed, not an enum, because IbanUnknownCountry and IbanInvalidLength report values read from the input.
IbanInvalidCharacters
Something outside A-Z and 0-9 survived normalisation (whitespace is stripped first).
IbanInvalidLength
The country is known and fixes the length at expected, but the input is actual long.
IbanTooShort
Under four characters (empty included), so the country and check digits aren't there to inspect yet. Keep typing.
IbanUnknownCountry
countryCode is not in the IBAN registry, so this is unsupported rather than mistyped.
MintedFailure
Why a minted value type refused its input.
ParseFailure<F extends MintedFailure, T>
A parse that failed, for the reason given.
ParseOutcome<F extends MintedFailure, T>
The result of parsing text: either the value, or the MintedFailure saying why not.
ParseSuccess<F extends MintedFailure, T>
A parse that produced value.
UuidFailure
Why a Uuid refused its input. Sealed, not an enum, because UuidWrongByteCount reports a count known only per call.
UuidMalformed
The text is not the canonical 8-4-4-4-12 hex form, wrapped or otherwise.
UuidWrongByteCount
Uuid.fromBytes got other than 16 bytes. Every 16-byte sequence is a valid UUID, so length is all it can reject.

Enums

DigitFailure
Why a Digit refused its input. One variant: a one-character grammar has one way to fail.
DigitsFailure
Why a Digits sequence refused its input. One variant: naming which element offended would not change the remedy.
EmailFailure
Why an Email refused its input. One variant, and that is the ceiling, not a shortcut: email_validator exposes a single bool, so a finer diagnosis would be a guess.
MonthFailure
Why a Month refused its input. One variant: a closed set of twelve has one way to miss.
PhoneNumberFailure
Why a PhoneNumber refused its input. Only unknownCountryCallingCode comes from the engine: phone_numbers_parser throws one of its five codes in practice, so the rest we check ourselves.
PhoneNumberType
UuidVariant
The variant of a Uuid: which layout family it belongs to, named by the variant bits (the first hex digit of the fourth group). See RFC 9562 ยง4.1.

Extension Types

Digit
A single decimal digit, 0-9.
Email
An email address, validated against the RFC 5322 grammar (via email_validator). Standard: RFC 5322.
Iban
An IBAN: validated for structure, country-specific length, and the mod-97 checksum (via iban_validator). Standard: ISO 13616.
Month
A month of the year, 1 (January) to 12 (December).
PhoneNumber
A phone number, validated and stored in its canonical E.164 form (via phone_numbers_parser). Standard: E.164.
Uuid
A UUID (Universally Unique IDentifier): 128 bits in the canonical 8-4-4-4-12 hex form, e.g. f81d4fae-7dec-11d0-a765-00a0c91e6bf6. Standard: RFC 9562, which obsoletes RFC 4122.

Exceptions / Errors

MintedFormatException
The FormatException raised when a minted value type fails to parse.