Skip to content

Commit

Permalink
submit validation-part1
Browse files Browse the repository at this point in the history
  • Loading branch information
peggy-quartech committed Nov 15, 2023
1 parent 9d12bfb commit badcfec
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 13 deletions.
78 changes: 66 additions & 12 deletions src/Spd.Manager.Cases/Licence/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,33 +298,87 @@ public class WorkerLicenceAppSubmitRequestValidator : AbstractValidator<WorkerLi
{
public WorkerLicenceAppSubmitRequestValidator()
{
RuleFor(r => r.LicenceAppId)
.NotEmpty();

RuleFor(r => r.WorkerLicenceTypeCode)
.NotEmpty();

RuleFor(r => r.ApplicationTypeCode)
.NotEmpty();

RuleFor(r => r.LicenceAppId).NotEmpty();
RuleFor(r => r.WorkerLicenceTypeCode).NotEmpty();
RuleFor(r => r.ApplicationTypeCode).NotEmpty();
RuleFor(r => r.isSoleProprietor).NotEmpty();
RuleFor(r => r.Surname).NotEmpty();
RuleFor(r => r.DateOfBirth).NotEmpty();
RuleFor(r => r.GenderCode).NotEmpty();
RuleFor(r => r.LicenceTermCode).NotEmpty();
RuleFor(r => r.HasExpiredLicence).NotEmpty();
RuleFor(r => r.ExpiredLicenceNumber).NotEmpty().When(r => r.HasExpiredLicence == true);
RuleFor(r => r.IsCanadianCitizen).NotEmpty();
RuleFor(r => r.CitizenshipDocument).NotEmpty();
RuleFor(r => r.HasCriminalHistory).NotEmpty();
RuleFor(r => r.HasBcDriversLicence).NotEmpty();
RuleFor(r => r.HairColourCode).NotEmpty();
RuleFor(r => r.EyeColourCode).NotEmpty();
RuleFor(r => r.Height).NotEmpty();
RuleFor(r => r.HeightUnitCode).NotEmpty();
RuleFor(r => r.Weight).NotEmpty();
RuleFor(r => r.WeightUnitCode).NotEmpty();
RuleFor(r => r.HasCriminalHistory).NotEmpty();
RuleFor(r => r.IsMailingTheSameAsResidential).NotEmpty();
RuleFor(r => r.ContactPhoneNumber).MaximumLength(15).NotEmpty();
RuleFor(r => r.ContactEmailAddress).MaximumLength(75).When(r => r.ContactEmailAddress != null);

//police officer
RuleFor(r => r.IsPoliceOrPeaceOfficer).NotEmpty();
RuleFor(r => r.PoliceOfficerRoleCode).NotEmpty().When(r => r.IsPoliceOrPeaceOfficer == true);
RuleFor(r => r.PoliceOfficerDocument).NotEmpty().When(r => r.IsPoliceOrPeaceOfficer == true);
RuleFor(r => r.PoliceOfficerDocument.LicenceDocumentTypeCode)
.Must(c => c == LicenceDocumentTypeCode.PoliceBackgroundLetterOfNoConflict)
.When(r => r.IsPoliceOrPeaceOfficer == true && r.PoliceOfficerDocument != null);

//mental health
RuleFor(r => r.IsTreatedForMHC).NotEmpty();
RuleFor(r => r.MentalHealthDocument).NotEmpty().When(r => r.IsTreatedForMHC == true);
RuleFor(r => r.MentalHealthDocument.LicenceDocumentTypeCode)
.Must(c => c == LicenceDocumentTypeCode.MentalHealthCondition)
.When(r => r.IsTreatedForMHC == true && r.MentalHealthDocument != null);

//citizenship
RuleFor(r => r.IsCanadianCitizen).NotEmpty();
RuleFor(r => r.CitizenshipDocument).NotEmpty();
RuleFor(r => r.CitizenshipDocument.LicenceDocumentTypeCode)
.Must(c => LicenceManager.WorkProofCodes.Contains(c))
.When(r => r.CitizenshipDocument != null && r.IsCanadianCitizen == false);
RuleFor(r => r.CitizenshipDocument.LicenceDocumentTypeCode)
.Must(c => LicenceManager.CitizenshipProofCodes.Contains(c))
.When(r => r.CitizenshipDocument != null && r.IsCanadianCitizen == true);
//todo: add more validation when the ui design settled.
RuleFor(r => r.CitizenshipDocument.ExpiryDate)
.NotEmpty()
.Must(d => d > DateTimeOffset.Now)
.When(r => r.CitizenshipDocument != null && r.IsCanadianCitizen == false && (r.CitizenshipDocument.LicenceDocumentTypeCode == LicenceDocumentTypeCode.WorkPermit || r.CitizenshipDocument.LicenceDocumentTypeCode == LicenceDocumentTypeCode.StudyPermit));

//additional gov id
RuleFor(r => r.AdditionalGovIdDocument)
.NotEmpty()
.Must(c => LicenceManager.GovIdCodes.Contains(c.LicenceDocumentTypeCode))
.When(r => r.CitizenshipDocument != null && (r.CitizenshipDocument.LicenceDocumentTypeCode != LicenceDocumentTypeCode.CanadianPassport && r.CitizenshipDocument.LicenceDocumentTypeCode != LicenceDocumentTypeCode.PermanentResidentCard));

//fingerprint
RuleFor(r => r.FingerprintProofDocument).NotEmpty();
RuleFor(r => r.FingerprintProofDocument.LicenceDocumentTypeCode)
.Must(c => c == LicenceDocumentTypeCode.ProofOfFingerprint);

//photo
RuleFor(r => r.UseBcServicesCardPhoto).NotEmpty();
RuleFor(r => r.IdPhotoDocument).NotEmpty().When(r => r.UseBcServicesCardPhoto == false);
RuleFor(r => r.IdPhotoDocument.LicenceDocumentTypeCode)
.Must(c => c == LicenceDocumentTypeCode.PhotoOfYourself)
.When(r => r.UseBcServicesCardPhoto == false && r.IdPhotoDocument != null);

//residential address
RuleFor(r => r.ResidentialAddressData).NotEmpty();
RuleFor(r => r.ResidentialAddressData.Province).NotEmpty().When(r => r.ResidentialAddressData != null);
RuleFor(r => r.ResidentialAddressData.City).NotEmpty().MaximumLength(100).When(r => r.ResidentialAddressData != null);
RuleFor(r => r.ResidentialAddressData.AddressLine1).NotEmpty().MaximumLength(100).When(r => r.ResidentialAddressData != null);
RuleFor(r => r.ResidentialAddressData.Country).NotEmpty().MaximumLength(100).When(r => r.ResidentialAddressData != null);
RuleFor(r => r.ResidentialAddressData.PostalCode).NotEmpty().MaximumLength(20).When(r => r.ResidentialAddressData != null);

//category
RuleFor(r => r.CategoryData).NotEmpty().Must(d => d.Count() > 0 && d.Count() < 7);


}
}
Expand Down
9 changes: 8 additions & 1 deletion src/Spd.Manager.Cases/Licence/LicenceManager.Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,19 @@ private LicenceDocumentTypeCode GetlicenceDocumentTypeCode(DocumentTypeEnum docu
LicenceDocumentTypeCode.WorkPermit,
LicenceDocumentTypeCode.StudyPermit,
LicenceDocumentTypeCode.DocumentToVerifyLegalWorkStatus,
LicenceDocumentTypeCode.CanadianCitizenship
};

public static List<LicenceDocumentTypeCode> CitizenshipProofCodes = new List<LicenceDocumentTypeCode> {
LicenceDocumentTypeCode.CanadianPassport,
LicenceDocumentTypeCode.BirthCertificate,
LicenceDocumentTypeCode.CertificateOfIndianStatus,
};

public static List<LicenceDocumentTypeCode> GovIdCodes = new List<LicenceDocumentTypeCode> {
LicenceDocumentTypeCode.DriversLicence,
LicenceDocumentTypeCode.CanadianFirearmsLicence,
LicenceDocumentTypeCode.BcServicesCard,
LicenceDocumentTypeCode.CertificateOfIndianStatus,
LicenceDocumentTypeCode.GovernmentIssuedPhotoId
};
}

0 comments on commit badcfec

Please sign in to comment.