diff --git a/web/backend/app/models/converter/text_to_moon.rb b/web/backend/app/models/converter/text_to_moon.rb index df0427b6..a10fa2cc 100644 --- a/web/backend/app/models/converter/text_to_moon.rb +++ b/web/backend/app/models/converter/text_to_moon.rb @@ -8,10 +8,10 @@ class TextToMoon CONVERT_SIZE = 4 attribute :text, :string - attribute :size, :integer, default: 20 + attribute :size, :integer, default: 10 validates :text, presence: true - validates :text, length: { minimum: 1, maximum: 20 } + validates :text, length: { minimum: 1, maximum: 10 } validates :text, format: { with: /\A[ぁ-んァ-ンa-zA-Z0-9ー0-9A-Za-z  ]+\z/, message: '変換できるのは全角半角英数字、ひらがなカタカナのみです。' } validates :size, numericality: { only_integer: true, greater_than_or_equal_to: 20, less_than_or_equal_to: 100 } diff --git a/web/backend/spec/models/converter/text_to_moon_spec.rb b/web/backend/spec/models/converter/text_to_moon_spec.rb index d807d0f1..3fb6d015 100644 --- a/web/backend/spec/models/converter/text_to_moon_spec.rb +++ b/web/backend/spec/models/converter/text_to_moon_spec.rb @@ -11,30 +11,30 @@ context 'textに半角全角英数字、ひらがなカタカナの文字が含まれているとき' do it 'ひらがなのみなのでエラーにならないことを確認' do - text_to_moon = Converter::TextToMoon.new(text: 'あいうえお', size: 20) + text_to_moon = Converter::TextToMoon.new(text: 'あいうえお', size: 10) expect(text_to_moon.valid?).to be true end it 'カタカナのみなのでエラーにならないことを確認' do - text_to_moon = Converter::TextToMoon.new(text: 'アイウエオ', size: 20) + text_to_moon = Converter::TextToMoon.new(text: 'アイウエオ', size: 10) expect(text_to_moon.valid?).to be true end it '半角英数字のみなのでエラーにならないことを確認' do - text_to_moon = Converter::TextToMoon.new(text: 'abcde12345', size: 20) + text_to_moon = Converter::TextToMoon.new(text: 'abcde12345', size: 10) expect(text_to_moon.valid?).to be true end it '全角英数字のみなのでエラーにならないことを確認' do - text_to_moon = Converter::TextToMoon.new(text: 'ABCDE12345', size: 20) + text_to_moon = Converter::TextToMoon.new(text: 'ABCDE12345', size: 10) expect(text_to_moon.valid?).to be true end it 'textとsizeに受け取ったパラメータが設定されていることを確認' do - text_to_moon = Converter::TextToMoon.new(text: 'ABCDE12345', size: 20) + text_to_moon = Converter::TextToMoon.new(text: 'ABCDE12345', size: 10) response = text_to_moon.call expect(response[:text]).to eq 'ABCDE12345' - expect(response[:size]).to eq 20 + expect(response[:size]).to eq 10 end end diff --git a/web/frontend/src/pages/TopPage.vue b/web/frontend/src/pages/TopPage.vue index a2aad515..6afa83d5 100644 --- a/web/frontend/src/pages/TopPage.vue +++ b/web/frontend/src/pages/TopPage.vue @@ -10,7 +10,7 @@ import { computed } from "vue"; import { ComputedRef } from "vue"; import { reactive } from "vue"; -const size = ref(20); +const size = ref(10); const text = ref(""); const isValid = ref(false); const response = ref([]); @@ -37,10 +37,10 @@ const inputNumberOnly = (inputValue: string): boolean | string => { const regex = /^[0-9]+$/; return regex.test(inputValue) || "数字を入力してください"; }; -const inputNumber20to100 = (inputValue: string): boolean | string => { - // 20 ~ 100の数字のみの入力を許可する - const regex = /^[2-9][0-9]$|^100$/; - return regex.test(inputValue) || "20 ~ 100の数字を入力してください"; +const inputNumber10to100 = (inputValue: string): boolean | string => { + // 10 ~ 100の数字のみの入力を許可する + const regex = /^[1-9][0-9]$|^100$/; + return regex.test(inputValue) || "10 ~ 100の数字を入力してください"; }; const inputText1to20 = (inputValue: string): boolean | string => { @@ -83,9 +83,9 @@ onErrorCaptured((err: Error) => {