fix(article): enforce maximum length for content validation (#109)

* fix(article): enforce maximum length for content validation

* fix(article): update content length validation to allow up to 65535 characters
This commit is contained in:
Gabriel Jablonski 2025-09-04 21:45:29 -03:00 committed by GitHub
parent 0b6d943faf
commit 3dac94e058
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -58,7 +58,7 @@ class Article < ApplicationRecord
validates :account_id, presence: true
validates :author_id, presence: true
validates :title, presence: true
validates :content, presence: true
validates :content, presence: true, length: { maximum: 65_535 }
# ensuring that the position is always set correctly
before_create :add_position_to_article

View File

@ -33,9 +33,9 @@ RSpec.describe Article do
end
it 'invalid when crossed the limit' do
article.content = 'a' * 25_001
article.content = 'a' * 70_000
article.valid?
expect(article.errors[:content]).to include('is too long (maximum is 20000 characters)')
expect(article.errors[:content]).to include('is too long (maximum is 65535 characters)')
end
end
end