Set min length
This commit is contained in:
parent
0019272687
commit
be41f79916
4 changed files with 8 additions and 8 deletions
|
@ -67,9 +67,9 @@ class Account < ApplicationRecord
|
||||||
format: NICKNAME_RE,
|
format: NICKNAME_RE,
|
||||||
uniqueness: { case_sensitive: false }
|
uniqueness: { case_sensitive: false }
|
||||||
|
|
||||||
validates :public_name, allow_nil: true, length: { in: 3..255 }
|
validates :public_name, allow_nil: true, length: { in: 1..255 }
|
||||||
|
|
||||||
validates :biography, allow_nil: true, length: { in: 3..10_000 }
|
validates :biography, allow_nil: true, length: { in: 1..10_000 }
|
||||||
|
|
||||||
validates :avatar, allow_nil: true, image: true
|
validates :avatar, allow_nil: true, image: true
|
||||||
|
|
||||||
|
|
|
@ -261,11 +261,11 @@ class InitialMigration < ActiveRecord::Migration[6.0]
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
constraint :accounts, :public_name, <<~SQL
|
constraint :accounts, :public_name, <<~SQL
|
||||||
public_name IS NULL OR is_good_limited_text(public_name, 3, 255)
|
public_name IS NULL OR is_good_limited_text(public_name, 1, 255)
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
constraint :accounts, :biography, <<~SQL
|
constraint :accounts, :biography, <<~SQL
|
||||||
biography IS NULL OR is_good_limited_text(biography, 3, 10000)
|
biography IS NULL OR is_good_limited_text(biography, 1, 10000)
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
constraint :federal_subjects, :english_name, <<~SQL
|
constraint :federal_subjects, :english_name, <<~SQL
|
||||||
|
|
|
@ -174,10 +174,10 @@ CREATE TABLE public.accounts (
|
||||||
biography text,
|
biography text,
|
||||||
person_id bigint,
|
person_id bigint,
|
||||||
contacts_list_id bigint NOT NULL,
|
contacts_list_id bigint NOT NULL,
|
||||||
CONSTRAINT biography CHECK (((biography IS NULL) OR public.is_good_limited_text(biography, 3, 10000))),
|
CONSTRAINT biography CHECK (((biography IS NULL) OR public.is_good_limited_text(biography, 1, 10000))),
|
||||||
CONSTRAINT guest_token CHECK (public.is_guest_token((guest_token)::text)),
|
CONSTRAINT guest_token CHECK (public.is_guest_token((guest_token)::text)),
|
||||||
CONSTRAINT nickname CHECK (public.is_nickname((nickname)::text)),
|
CONSTRAINT nickname CHECK (public.is_nickname((nickname)::text)),
|
||||||
CONSTRAINT public_name CHECK (((public_name IS NULL) OR public.is_good_limited_text((public_name)::text, 3, 255)))
|
CONSTRAINT public_name CHECK (((public_name IS NULL) OR public.is_good_limited_text((public_name)::text, 1, 255)))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ RSpec.describe Account do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
is_expected.to \
|
is_expected.to \
|
||||||
validate_length_of(:public_name).is_at_least(3).is_at_most(255)
|
validate_length_of(:public_name).is_at_least(1).is_at_most(255)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when it was set to blank value' do
|
context 'when it was set to blank value' do
|
||||||
|
@ -158,7 +158,7 @@ RSpec.describe Account do
|
||||||
|
|
||||||
it do
|
it do
|
||||||
is_expected.to \
|
is_expected.to \
|
||||||
validate_length_of(:biography).is_at_least(3).is_at_most(10_000)
|
validate_length_of(:biography).is_at_least(1).is_at_most(10_000)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when it was set to blank value' do
|
context 'when it was set to blank value' do
|
||||||
|
|
Reference in a new issue