Skip to content

v1.5.0

Latest
Compare
Choose a tag to compare
@kylekthompson kylekthompson released this 12 Apr 04:05
· 4 commits to main since this release
7ac2719

Support sampling of validation to make Strict more Lenient

This release exposes configuration options to change the sample rate for validating attributes, parameters, and return values. This new capability means that you can validate all the time in your tests and only 10% of the time in production, for example. Additionally, you can apply different sample rates in performance sensitive areas of code if you need to disable validation entirely:

# Globally

Strict.configure do |c|
  c.sample_rate = 0.75 # run validation ~75% of the time
end

Strict.configure do |c|
  c.sample_rate = 0 # disable validation (Strict becomes Lenient)
end

Strict.configure do |c|
  c.sample_rate = 0 # always run validation
end

# Locally within the block (only applies to the current thread)

Strict.with_overrides(sample_rate: 0) do
  # Use Strict as you normally would

  Strict.with_overrides(sample_rate: 0.5) do
    # Overrides can be nested
  end
end

What's Changed

Full Changelog: v1.4.0...v1.5.0