fixed bugs from qa test Co-authored-by: Jipson George <152465898+Jipson-cosq@users.noreply.github.com> Co-authored-by: DhanshCOSQ <dhanshas@cosq.net> Reviewed-on: cosqnet/telemednet#7 Co-authored-by: Jipson George <jipsongeorge@cosq.net> Co-committed-by: Jipson George <jipsongeorge@cosq.net>
135 lines
3.6 KiB
Dart
135 lines
3.6 KiB
Dart
import 'package:medora/data/models/doctor.dart';
|
|
|
|
class ValidationHelper {
|
|
// Basic regex patterns
|
|
static final RegExp nameRegex = RegExp(r'^[a-zA-Z\s]{2,50}$');
|
|
static final RegExp experienceRegex = RegExp(r'^\d{1,2}$');
|
|
static final RegExp licenseRegex = RegExp(r'^[A-Z0-9-]{5,15}$');
|
|
static final RegExp postalCodeRegex = RegExp(r'^\d{6}$');
|
|
static final RegExp buildingRegex = RegExp(r'^[a-zA-Z0-9\s\-\/]{1,50}$');
|
|
static final RegExp streetRegex = RegExp(r'^[a-zA-Z0-9\s\,\-\/]{5,100}$');
|
|
|
|
// Validation error messages
|
|
static const String nameError =
|
|
'Name should be 2-50 characters long and contain only letters';
|
|
static const String experienceError =
|
|
'Years of experience should be a valid number between 0-99';
|
|
static const String licenseError =
|
|
'License number should be 5-15 alphanumeric characters';
|
|
static const String postalCodeError =
|
|
'Postal code should be exactly 6 digits';
|
|
static const String buildingError =
|
|
'Building/Floor details should be 1-50 characters';
|
|
static const String streetError = 'Street address should be 5-100 characters';
|
|
static const String requiredFieldError = 'This field is required';
|
|
static const String qualificationError =
|
|
'At least one qualification is required';
|
|
static const String achievementError =
|
|
'Achievement should be between 5-200 characters';
|
|
}
|
|
|
|
class DoctorController {
|
|
final Doctor model;
|
|
Map<String, String> validationErrors = {};
|
|
|
|
DoctorController() : model = Doctor();
|
|
|
|
bool validateAchievement(String achievement) {
|
|
if (achievement.length < 5 || achievement.length > 200) {
|
|
validationErrors['achievement'] = ValidationHelper.achievementError;
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void updateSpeciality(String speciality) {
|
|
model.speciality = speciality;
|
|
}
|
|
|
|
void updateAchievements(List<String> achievements) {
|
|
model.achievements = List<String>.from(achievements);
|
|
}
|
|
|
|
void addAchievement(String achievement) {
|
|
if (validateAchievement(achievement)) {
|
|
model.achievements!.add(achievement);
|
|
}
|
|
}
|
|
|
|
void removeAchievement(String achievement) {
|
|
model.achievements!.remove(achievement);
|
|
}
|
|
|
|
void updateYearsOfExperience(String years) {
|
|
model.yearsOfExperience = years;
|
|
}
|
|
|
|
void updateLicenseNumber(String license) {
|
|
model.licenseNumber = license;
|
|
}
|
|
|
|
void updateProfileDescription(String description) {
|
|
model.profileDescription = description;
|
|
}
|
|
|
|
void updateDigitalSignature(String signature) {
|
|
model.digitalSignature = signature;
|
|
}
|
|
|
|
void updateProfileImage(String profileImage) {
|
|
model.profileImage = profileImage;
|
|
}
|
|
|
|
void updateTitle(String title) {
|
|
model.title = title;
|
|
}
|
|
|
|
void updateSurName(String surName) {
|
|
model.surName = surName;
|
|
}
|
|
|
|
void updateMiddleName(String middleName) {
|
|
model.middleName = middleName;
|
|
}
|
|
|
|
void updateLastName(String firstName) {
|
|
model.firstName = firstName;
|
|
}
|
|
|
|
void addQualification(String qualification) {
|
|
model.qualifications!.add(qualification);
|
|
}
|
|
|
|
void removeQualification(String qualification) {
|
|
model.qualifications!.remove(qualification);
|
|
}
|
|
|
|
void updateFloorBuilding(String floorBuilding) {
|
|
model.floorBuilding = floorBuilding;
|
|
}
|
|
|
|
void updateStreet(String street) {
|
|
model.street = street;
|
|
}
|
|
|
|
void updateCity(String city) {
|
|
model.city = city;
|
|
}
|
|
|
|
void updateState(String state) {
|
|
model.state = state;
|
|
}
|
|
|
|
void updateCountry(String country) {
|
|
model.country = country;
|
|
}
|
|
|
|
void updatePostalCode(String postalCode) {
|
|
model.postalCode = postalCode;
|
|
}
|
|
|
|
void updateAddressType(String addressType) {
|
|
model.addressType = addressType;
|
|
}
|
|
}
|