Once, at startup
Validity.configure { } replaces the default configuration, the one every validation uses unless it is given another:
For one call
Validity { } creates a configuration that starts from the default one and changes only what its block says. Pass it
to validate: the default configuration does not change, so other requests keep theirs.
The codes stay the same in every language, which is what lets programs ignore the messages.
Every entry takes one:
validate(validity), validateBlocking(validity), the OrThrow versions, and, for a
ContextualValidatable, validate(context, validity). The configuration reaches the nested objects
and elements too.
Common uses
One language per request
One language per request
Build one
Validity per language at startup, and pick it from the Accept-Language of the request:A fixed clock in tests
A fixed clock in tests
Rules about time read the clock of the configuration, so a test can fix “now” for one call without touching the
default:
The time zone of a user
The time zone of a user
“Today” depends on the zone. Give the call the clock of the user’s zone:
Validity { } builds its configuration when it is created, on top of the default of that moment. Create the ones you
reuse, such as one per language, after Validity.configure, and keep them in a value.