Minor updates involving cosmetic changes have been omitted from this list. See https://github.com/cowwoc/requirements.java/commits/master for a full list.
- Bugfix: Added missing
strip-ansi
dependency.
- Improvements
- Updated dependencies
- Improvements
size().isEqualTo()
andisNotEqualTo()
now include the array value in the exception context.- When referencing to a variable number of elements, always use the plural form of a type (e.g.
actual must contain X entries
even ifX
is one).
- Breaking changes:
- Replaced
validateThat()
withcheckIf()
. - Validation methods now contain the type of value being validated (e.g.
requireThatString()
instead ofrequireThat()
). This is the only way to ensure that the return type of the method matches the compile-time type of the value being validated. - Use consistent parameter ordering across the entire API:
(value, name)
.- Adding contextual information now looks like this:
requireThat().withContext(value, name)
- Adding contextual information now looks like this:
- Added
Validator.and(validation: (validator: S) => void)
to nest validations. - Replaced
isBetweenClosed(min, max)
withisBetween(min, true, max, true)
. - Removed ability to configure validators in order to simplify API.
- Renamed
StringValidator.isInteger()
toasPrimitiveInteger()
andisCharacter()
toasPrimitiveCharacter()
. - Replaced
Validator.elseGetMessages()
withValidator.getFailures().getMessages()
. - Replaced
Validator.elseGetException()
withValidator.getFailures().getException()
. - Dropped the
isOneOf()
andisNotOneOf()
functionality yet again. I haven't figured out a good design for this yet.
- Replaced
- New features:
- Added
validationFailed()
andgetValueOrDefault()
to all validators. - Added
StringValidator.doesNotContainWhitespace()
. - Added
StringValidator.matches(regex)
. - Replaced
ClassValidator.isSupertypeOf()
,isSubtypeOf()
withType.isSupertypeOf()
.
- Added
- Improvements
- If
checkIf()
cannot run validations due to a null value, the expected conditions are still reported.
- If
- Breaking changes: The following
ObjectVerifier
methods now throwTypeError
instead ofRangeError
if the actual value does not have the desired type:isNull()
isNotNull()
isDefined()
isUndefined()
isDefinedAndNotNull
isUndefinedOrNull
isBoolean()
isNumber()
isString()
isInetAddress()
isClass()
isArray()
isSet()
isMap()
isPrimitive()
isTypeOf()
isInstanceOf()
- Bugfix: 3.3.2 release was missing browser files.
- Bugfix: Assertions were being thrown if class names were changed code minifiers.
- Bugfix: Output ESM format to browsers instead of IIFE.
- Breaking changes
- Removed methods that transform the actual value, such as asString() or trim(). Users are expected to handle this outside the library.
- Removed consumer methods not used to validate class properties (e.g., asStringConsumer()).
- Renamed isNotDefined() to isUndefined().
- Renamed isNotFinite() to isInfinite().
- Removed all deprecated method declarations.
- Improvements
- isNull() changes the compile-time type of T to
null
. - isNotNull() changes the compile-time type of T to not
null
.
- isNull() changes the compile-time type of T to
- Improvement: getActual() now returns a specific type instead of
unknown
.
-
Breaking changes:
- Migrated from default to named-exports to improve documentation and code-complete discoverability.
-
Bugfix: Documentation was missing all the interfaces.
-
Removed all babel dependencies.
-
Breaking changes:
- Dropped support for CommonJS.
- Replaced
Requirements.assertThat(actual, name)
byassertThat(requirements -> requirements.requireThat(actual, name))
andassertThatAndReturn(requirements -> requirements.requireThat(actual, name))
. The latter is used for assertions with a return value. This change improves the runtime performance ofassertThat()
and reduces code duplication across the library. - Removed
Object.isActualAvailable()
in favor ofRequirements.assumeThatEnabled()
. Requirements
no longer returns copies on modification. AddedRequirements.copy()
to facilitate old behavior.
-
Documentation: Migrated from JSDoc to Typedoc.
-
Build: Migrated from yarn to pnpm.
- Documentation fixes
- Breaking changes
- Changed the meaning of
ObjectValidator/Verifier.isTypeOf()
's parameters.type
now expects values returned bytypeof()
.
- Changed the meaning of
- Security fixes
- Security fixes
- Improvements
- Added ObjectValidator/Verifier.asBoolean().
- Added ObjectValidator/Verifier.isActualAvailable().
- Added StringValidator/Verifier.isTrimmed().
- Use interfaces to hide whether we return a normal or no-op implementation of a validator or verifier.
- Breaking changes
- Removed URI (https://medialize.github.io/URI.js/) in favor of built-in URL.
- Because built-in URL is always absolute, all corresponding validators were removed.
- Improvements
- Converted code to typescript.
- Copy now includes typescript definition files.
- Bugfixes
- Documentation:
Configuration.getContext()
returns aMap<string, string>
not anArray<string, string>
.
- Documentation:
- Improvements
- Resolved CVE-2020-7662 security vulnerability by upgrading dependencies.
- Bugfixes
ValidationFailure.mergeContext()
was throwing an error if the global configuration contained a failure context.
- Bugfixes
requireThatInstanceOf()
failed with: "type" must be a type.
- Improvements
- If a failure message is longer than the terminal width, push the expected value from the failure message to the error context. This helps failure messages remain readable in the face of long values.
- Added
GlobalConfiguration.getTerminalWidth()
,withDefaultTerminalWidth()
,withTerminalWidth()
.
- Improvements
- Improved diff output for arrays, multiline strings.