LunchPick(오늘 뭐 먹Z?) Flutter 앱의 초기 구현입니다. 주요 기능: - 네이버 지도 연동 맛집 추가 - 랜덤 메뉴 추천 시스템 - 날씨 기반 거리 조정 - 방문 기록 관리 - Bluetooth 맛집 공유 - 다크모드 지원 기술 스택: - Flutter 3.8.1+ - Riverpod 상태 관리 - Hive 로컬 DB - Clean Architecture 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
92 lines
2.3 KiB
Dart
92 lines
2.3 KiB
Dart
class Validators {
|
|
static String? validateRestaurantName(String? value) {
|
|
if (value == null || value.trim().isEmpty) {
|
|
return '맛집 이름을 입력해주세요';
|
|
}
|
|
if (value.trim().length < 2) {
|
|
return '맛집 이름은 2자 이상이어야 합니다';
|
|
}
|
|
if (value.trim().length > 50) {
|
|
return '맛집 이름은 50자 이하여야 합니다';
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static String? validateMemo(String? value) {
|
|
if (value != null && value.length > 200) {
|
|
return '메모는 200자 이하여야 합니다';
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static String? validateLatitude(String? value) {
|
|
if (value == null || value.isEmpty) {
|
|
return null;
|
|
}
|
|
|
|
final lat = double.tryParse(value);
|
|
if (lat == null) {
|
|
return '올바른 위도 값을 입력해주세요';
|
|
}
|
|
|
|
if (lat < -90 || lat > 90) {
|
|
return '위도는 -90도에서 90도 사이여야 합니다';
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
static String? validateLongitude(String? value) {
|
|
if (value == null || value.isEmpty) {
|
|
return null;
|
|
}
|
|
|
|
final lng = double.tryParse(value);
|
|
if (lng == null) {
|
|
return '올바른 경도 값을 입력해주세요';
|
|
}
|
|
|
|
if (lng < -180 || lng > 180) {
|
|
return '경도는 -180도에서 180도 사이여야 합니다';
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
static String? validateAddress(String? value) {
|
|
if (value != null && value.length > 100) {
|
|
return '주소는 100자 이하여야 합니다';
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static String? validateCategory(String? value) {
|
|
if (value == null || value.isEmpty) {
|
|
return '카테고리를 선택해주세요';
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static String? validateRating(double? value) {
|
|
if (value != null && (value < 0 || value > 5)) {
|
|
return '평점은 0에서 5 사이여야 합니다';
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static bool isValidEmail(String? email) {
|
|
if (email == null || email.isEmpty) return false;
|
|
|
|
final emailRegex = RegExp(
|
|
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
|
|
);
|
|
return emailRegex.hasMatch(email);
|
|
}
|
|
|
|
static bool isValidPhoneNumber(String? phone) {
|
|
if (phone == null || phone.isEmpty) return false;
|
|
|
|
final phoneRegex = RegExp(r'^[0-9-+() ]+$');
|
|
return phoneRegex.hasMatch(phone) && phone.length >= 10;
|
|
}
|
|
} |