npm fluentvalidation-ts 4.1.0
v4.1.0

latest release: 5.0.0
3 months ago

New Features ✨

Improvements to .notNull and .null

Up to now, the .notNull and .null rules implicitly included undefined in the definition of "null" - this behaviour was chosen for simplicity, but doesn't allow for "strict" (triple-equals) null-checks in cases where null vs undefined semantics are important.

Both rules now accept an optional ruleOptions object - this is comprised of a single includeUndefined property that controls whether or not to include undefined in the definition of "null".

  • { includeUndefined: true } - in this case undefined is considered a "null" value
  • { includeUndefined: false } - in this case undefined is not considered a "null" value.

If not provided, the ruleOptions object defaults to { includeUndefined: true } - this decision has been taken to maintain backwards compatibility.

See the following documentation pages for more information:

[NEW] Introducing .notUndefined and .undefined

Given the above change, it seemed only logical to introduce complementary .notUndefined and .undefined rules to provide a complete set of rules for dealing with nullable and optional properties.

Both rules should be fairly self-explanatory - please refer to the documentation for more information:

Issues

This release addresses the null vs undefined semantic restriction as raised in #30.

Don't miss a new fluentvalidation-ts release

NewReleases is sending notifications on new releases.