feat: implement server-side validation for mobile numbers and national codes across multiple endpoints

This commit is contained in:
hamed
2026-06-20 12:28:36 +03:30
parent 6fc456522a
commit f9678026a8
12 changed files with 487 additions and 9 deletions
+5 -2
View File
@@ -174,8 +174,11 @@ class BlogController extends BaseController
public function create(Request $request, #[CurrentUser] User $user): JsonResponse
{
$data = json_decode($request->getContent(), true) ?? [];
$title = trim($data['title'] ?? '');
$body = trim($data['body'] ?? '');
if ((isset($data['title']) && !is_string($data['title'])) || (isset($data['body']) && !is_string($data['body']))) {
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'title و body باید رشته باشند', 422);
}
$title = trim((string) ($data['title'] ?? ''));
$body = trim((string) ($data['body'] ?? ''));
if (empty($title) || empty($body)) {
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'title و body الزامی است', 422);