discourse/spec/components/validators
Martin Brennan dba6a5eabf
FEATURE: Humanize file size error messages (#14398)
The file size error messages for max_image_size_kb and
max_attachment_size_kb are shown to the user in the KB
format, regardless of how large the limit is. Since we
are going to support uploading much larger files soon,
this KB-based limit soon becomes unfriendly to the end
user.

For example, if the max attachment size is set to 512000
KB, this is what the user sees:

> Sorry, the file you are trying to upload is too big (maximum
size is 512000KB)

This makes the user do math. In almost all file explorers that
a regular user would be familiar width, the file size is shown
in a format based on the maximum increment (e.g. KB, MB, GB).

This commit changes the behaviour to output a humanized file size
instead of the raw KB. For the above example, it would now say:

> Sorry, the file you are trying to upload is too big (maximum
size is 512 MB)

This humanization also handles decimals, e.g. 1536KB = 1.5 MB
2021-09-22 07:59:45 +10:00
..
allowed_ip_address_validator_spec.rb
category_search_priority_weights_validator_spec.rb
css_color_validator_spec.rb
email_setting_validator_spec.rb
email_validator_spec.rb
enable_invite_only_validator_spec.rb
enable_local_logins_via_email_validator_spec.rb
enable_sso_validator_spec.rb
external_system_avatars_validator_spec.rb
group_setting_validator_spec.rb
integer_setting_validator_spec.rb
ip_address_format_validator_spec.rb
max_emojis_validator_spec.rb
max_username_length_validator_spec.rb
min_username_length_validator_spec.rb
password_validator_spec.rb
post_validator_spec.rb
quality_title_validator_spec.rb
regex_presence_validator_spec.rb
regex_setting_validator_spec.rb
reply_by_email_address_validator_spec.rb
reply_by_email_enabled_validator_spec.rb
selectable_avatars_enabled_validator_spec.rb
sso_overrides_email_validator_spec.rb
string_setting_validator_spec.rb
topic_title_length_validator_spec.rb
unicode_username_allowlist_validator_spec.rb
unicode_username_validator_spec.rb
upload_validator_spec.rb
url_validator_spec.rb
user_full_name_validator_spec.rb
username_setting_validator_spec.rb