36 lines
832 B
Dart
36 lines
832 B
Dart
import 'dart:developer';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
class ValidatorUtil {
|
|
static bool isValidEmail(String email) {
|
|
if (RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(email)) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
static bool isValidPassword(String password) {
|
|
if (password.length >= 8) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
static String toISO8601(String format, String value) {
|
|
DateFormat dateFormat = DateFormat(format);
|
|
DateTime dateTime = dateFormat.parse(value);
|
|
|
|
return dateTime.toIso8601String();
|
|
}
|
|
|
|
static String toLocalDateTime(String format, String value) {
|
|
DateFormat dateFormat = DateFormat(format);
|
|
DateTime dateTime = dateFormat.parse(value);
|
|
|
|
return DateFormat('dd/MM/yyyy HH:mm:ss').format(dateTime);
|
|
}
|
|
}
|