Extend NumericalityValidator to check precision and scale

Use new checks on Unit.multiplier
Closes #28
This commit is contained in:
2024-12-07 20:16:43 +01:00
parent 25ac126df9
commit 15a5515c99
5 changed files with 27 additions and 2 deletions

View File

@@ -1,5 +1,9 @@
require 'core_ext/big_decimal_scientific_notation'
ActiveSupport.on_load :active_record do
ActiveModel::Validations::NumericalityValidator.prepend CoreExt::ActiveModel::Validations::NumericalityValidatesPrecisionAndScale
end
ActiveSupport.on_load :action_dispatch_system_test_case do
prepend CoreExt::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelperUniqueId
end

View File

@@ -1,4 +1,8 @@
en:
errors:
messages:
precision_exceeded: must not exceed %{value} significant digits
scale_exceeded: must not exceed %{value} decimal digits
activerecord:
attributes:
unit: