Performance: Length validation
MEDIUM IMPACT
Length validation affects server response time and user experience by adding checks before saving data, impacting form submission speed.
validates :username, length: { minimum: 3, maximum: 50 }validates :username, length: { minimum: 3, maximum: 50, tokenizer: ->(str) { str.scan(/\w+/) } }| Pattern | Server CPU Cost | Validation Time | User Input Responsiveness | Verdict |
|---|---|---|---|---|
| Complex length validation with custom tokenizer | High | Slower (~20ms extra) | Lower (delays response) | [X] Bad |
| Simple length validation with min/max | Low | Faster (~5ms) | Higher (quicker response) | [OK] Good |