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 FEATURE: Change very high/low search priority to rank at absolute ends. 2021-03-09 09:20:37 +08:00
css_color_validator_spec.rb FIX: Validate email_accent_bg_color color (#13778) 2021-07-22 17:42:47 +03:00
email_setting_validator_spec.rb
email_validator_spec.rb FIX: use allowlist and blocklist terminology (#10209) 2020-07-27 10:23:54 +10:00
enable_invite_only_validator_spec.rb FEATURE: Rename 'Discourse SSO' to DiscourseConnect (#11978) 2021-02-08 10:04:33 +00:00
enable_local_logins_via_email_validator_spec.rb
enable_sso_validator_spec.rb FEATURE: Rename 'Discourse SSO' to DiscourseConnect (#11978) 2021-02-08 10:04:33 +00:00
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 DEV: Correct typos and spelling mistakes (#12812) 2021-05-21 11:43:47 +10:00
max_username_length_validator_spec.rb
min_username_length_validator_spec.rb
password_validator_spec.rb
post_validator_spec.rb FEATURE: Treat emoji or similar characters as one (#12482) 2021-03-24 16:47:35 +02:00
quality_title_validator_spec.rb FEATURE: Improve errors when title is invalid (#11149) 2020-11-11 15:11:36 +02:00
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 DEV: Make site setting type uploaded_image_list use upload IDs (#10401) 2020-10-13 16:17:06 +03:00
sso_overrides_email_validator_spec.rb FEATURE: Rename 'Discourse SSO' to DiscourseConnect (#11978) 2021-02-08 10:04:33 +00:00
string_setting_validator_spec.rb
topic_title_length_validator_spec.rb
unicode_username_allowlist_validator_spec.rb FIX: use allowlist and blocklist terminology (#10209) 2020-07-27 10:23:54 +10:00
unicode_username_validator_spec.rb
upload_validator_spec.rb FEATURE: Humanize file size error messages (#14398) 2021-09-22 07:59:45 +10:00
url_validator_spec.rb
user_full_name_validator_spec.rb
username_setting_validator_spec.rb