-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidation.java
More file actions
36 lines (29 loc) · 958 Bytes
/
Validation.java
File metadata and controls
36 lines (29 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package utils;
import java.time.LocalDate;
public class Validation {
// ✅ Email validation
public static boolean isValidEmail(String email) {
return email.contains("@") && email.contains(".");
}
// ✅ Password validation
public static boolean isValidPassword(String password) {
return password.length() >= 6;
}
// ✅ Seat validation
public static boolean isValidSeats(int requested, int available) {
return requested > 0 && requested <= available;
}
// ✅ Date validation (no past dates)
public static boolean isFutureDate(String date) {
try {
LocalDate inputDate = LocalDate.parse(date);
return !inputDate.isBefore(LocalDate.now());
} catch (Exception e) {
return false;
}
}
// ✅ ID validation
public static boolean isValidId(int id) {
return id > 0;
}
}