Class: SignalValidator

Inherits:
AccountNameValidator show all
Defined in:
lib/signal_validator.rb

Overview

Validates Signal usernames. Signal introduced usernames in 2024; they consist of a base name and a numeric discriminator separated by a period:

<base>.<digits>
  • Base: starts with a letter, contains letters, digits, and underscores.

  • Discriminator: two or more digits (leading zeros allowed, e.g. ‘0123`).

  • Combined length 3-32 characters (matching Signal’s UI constraints).

The following error message keys are used to localize invalid usernames:

| | | |:—————————–|:—————————————————————| | ‘signal_too_short` | Username is less than 3 characters. | | `signal_too_long` | Username is over 32 characters. | | `signal_invalid_format` | Username doesn’t match ‘<base>.<digits>` with a valid base. |

Options


| | | |:————-|:————————————————-| | ‘:message` | A custom message to use if the username is invalid. | | `:allow_nil` | If true, `nil` values are allowed. |

Examples:

validates :signal_username, signal: true

Constant Summary collapse

FORMAT =
/\A[A-Za-z][A-Za-z0-9_]*\.\d{2,}\z/.freeze

Method Summary

Methods inherited from AccountNameValidator

add_validation, error_key_prefix, first_char, max_length, min_length, valid_chars, #validate_each