1
0
Fork 0

Set min length

This commit is contained in:
Alex Kotov 2019-07-23 01:56:11 +05:00
parent 0019272687
commit be41f79916
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 8 additions and 8 deletions

View file

@ -67,9 +67,9 @@ class Account < ApplicationRecord
format: NICKNAME_RE,
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

View file

@ -261,11 +261,11 @@ class InitialMigration < ActiveRecord::Migration[6.0]
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
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
constraint :federal_subjects, :english_name, <<~SQL

View file

@ -174,10 +174,10 @@ CREATE TABLE public.accounts (
biography text,
person_id bigint,
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 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)))
);

View file

@ -121,7 +121,7 @@ RSpec.describe Account do
it do
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
context 'when it was set to blank value' do
@ -158,7 +158,7 @@ RSpec.describe Account do
it do
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
context 'when it was set to blank value' do