電話番号の確認

このコミットが含まれているのは:
守矢諏訪子 2021-11-10 11:42:07 +09:00
コミット d898bedfe5
3個のファイルの変更60行の追加7行の削除

ファイルの表示

@ -29,9 +29,20 @@ class ChildrenController extends Controller {
} }
public function registerTemporary (Request $r) { public function registerTemporary (Request $r) {
// 電話番号の文字数。
Validator::extend('tel_size', function ($attribute, $value, $params, $validator) {
try {
return strlen((string)$value) == 10 || strlen((string)$value) == 11;
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return false;
}
});
$validate = Validator::make($r->all(), [ $validate = Validator::make($r->all(), [
'tel' => 'required|unique:children|numeric|digits_between:0,99999999999|starts_with:0' 'tel' => 'required|unique:children|numeric|starts_with:0|tel_size'
]); ]);
if ($validate->fails()) { if ($validate->fails()) {
// バリデーションエラー // バリデーションエラー
return ['status_code' => 422, 'error_messages' => $validate->errors()]; return ['status_code' => 422, 'error_messages' => $validate->errors()];
@ -155,8 +166,18 @@ KIKI承知システムを使って「聞いてない」「言ってない
} }
public function requestPassword (Request $r) { public function requestPassword (Request $r) {
// 電話番号の文字数。
Validator::extend('tel_size', function ($attribute, $value, $params, $validator) {
try {
return strlen((string)$value) == 10 || strlen((string)$value) == 11;
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return false;
}
});
$validate = Validator::make($r->all(), [ $validate = Validator::make($r->all(), [
'tel' => 'required|numeric|digits_between:0,99999999999|starts_with:0', 'tel' => 'required|numeric|starts_with:0|tel_size'
]); ]);
if ($validate->fails()) { if ($validate->fails()) {
@ -395,10 +416,20 @@ https://kikikan.jp/c-account/forgot-password/reset/'.$token;
return ['status_code' => 400, 'error_messages' => ['子の更新に失敗しました。']]; return ['status_code' => 400, 'error_messages' => ['子の更新に失敗しました。']];
} }
// 電話番号の文字数。
Validator::extend('tel_size', function ($attribute, $value, $params, $validator) {
try {
return strlen((string)$value) == 10 || strlen((string)$value) == 11;
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return false;
}
});
// バリデーションエラー // バリデーションエラー
$validate = Validator::make($r->all(), [ $validate = Validator::make($r->all(), [
'email' => 'required|max:255|email', 'email' => 'required|max:255|email',
'tel' => 'required|numeric|digits_between:0,99999999999|starts_with:0', 'tel' => 'required|numeric|starts_with:0|tel_size',
'last_name' => 'required|max:100', 'last_name' => 'required|max:100',
'first_name' => 'required|max:100', 'first_name' => 'required|max:100',
'identity' => 'required|max:20|alpha_num', 'identity' => 'required|max:20|alpha_num',

ファイルの表示

@ -113,14 +113,25 @@ class FathersController extends Controller {
} }
public function registerMain (Request $r) { public function registerMain (Request $r) {
// 電話番号の文字数。
Validator::extend('tel_size', function ($attribute, $value, $params, $validator) {
try {
return strlen((string)$value) == 10 || strlen((string)$value) == 11;
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return false;
}
});
$validate = Validator::make($r->all(), [ $validate = Validator::make($r->all(), [
'token' => 'required', 'token' => 'required',
'password' => 'required|min:8|max:72|confirmed', 'password' => 'required|min:8|max:72|confirmed',
'company' => 'max:100', 'company' => 'max:100',
'image' => 'max:1024|mimes:jpg,png,gif', 'image' => 'max:1024|mimes:jpg,png,gif',
'profile' => 'max:1000', 'profile' => 'max:1000',
'tel' => 'required|unique:children|numeric|digits_between:0,99999999999|starts_with:0', 'tel' => 'required|unique:fathers|numeric|starts_with:0|tel_size',
]); ]);
if ($validate->fails()) { if ($validate->fails()) {
// バリデーションエラー // バリデーションエラー
return ['status_code' => 422, 'error_messages' => $validate->errors()]; return ['status_code' => 422, 'error_messages' => $validate->errors()];
@ -310,12 +321,22 @@ class FathersController extends Controller {
return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']]; return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']];
} }
// 電話番号の文字数。
Validator::extend('tel_size', function ($attribute, $value, $params, $validator) {
try {
return strlen((string)$value) == 10 || strlen((string)$value) == 11;
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return false;
}
});
// バリデーションエラー // バリデーションエラー
$validate = Validator::make($r->all(), [ $validate = Validator::make($r->all(), [
'email' => 'required|max:255|email', 'email' => 'required|max:255|email',
'company' => 'max:100', 'company' => 'max:100',
'profile' => 'max:1000', 'profile' => 'max:1000',
'tel' => 'required|numeric|digits_between:0,99999999999|starts_with:0', 'tel' => 'required|numeric|starts_with:0|tel_size'
]); ]);
if ($validate->fails()) { if ($validate->fails()) {

ファイルの表示

@ -24,9 +24,9 @@ return [
'before' => 'The :attribute must be a date before :date.', 'before' => 'The :attribute must be a date before :date.',
'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
'between' => [ 'between' => [
'numeric' => 'The :attribute must be between :min and :max.', 'numeric' => ' :attribute は :min ・ :max 文字です。',
'file' => 'The :attribute must be between :min and :max kilobytes.', 'file' => 'The :attribute must be between :min and :max kilobytes.',
'string' => 'The :attribute must be between :min and :max characters.', 'string' => ' :attribute は :min ・ :max 文字です。',
'array' => 'The :attribute must have between :min and :max items.', 'array' => 'The :attribute must have between :min and :max items.',
], ],
'boolean' => 'The :attribute field must be true or false.', 'boolean' => 'The :attribute field must be true or false.',
@ -119,6 +119,7 @@ return [
], ],
'starts_with' => 'The :attribute must start with one of the following: :values.', 'starts_with' => 'The :attribute must start with one of the following: :values.',
'string' => 'The :attribute must be a string.', 'string' => 'The :attribute must be a string.',
'tel_size' => '電話番号は10・11文字です。',
'timezone' => 'The :attribute must be a valid zone.', 'timezone' => 'The :attribute must be a valid zone.',
'unique' => '同じ :attribute は使用できません。', 'unique' => '同じ :attribute は使用できません。',
'uploaded' => 'The :attribute failed to upload.', 'uploaded' => 'The :attribute failed to upload.',