SSR-627 Date Of Loss must be within the last 10 years
This commit is contained in:
parent
716a1c4fc5
commit
a6b5ac7ab4
2 changed files with 13 additions and 1 deletions
|
|
@ -41,6 +41,8 @@ const errorMessages = Object.freeze({
|
|||
LOSS_STATE_REQUIRED: 'Please select an option',
|
||||
LOSS_DATE_REQUIRED:
|
||||
'Please select a date. Format must be MM/DD/YYYY and the date must be not in the future',
|
||||
DAMAGE_DATE_REQUIREMENT:
|
||||
'Damage date must be within the past 10 years',
|
||||
DAMAGE_OPTION_REQUIRED: 'Please select an option',
|
||||
|
||||
POLICYHOLDER_FIRST_NAME_REQUIRED: 'Please enter the policyholder first name',
|
||||
|
|
|
|||
|
|
@ -198,6 +198,16 @@ defineRule(
|
|||
'policy-zip-format',
|
||||
regex(/(^\d{5}$)|(^\d{5}-\d{4}$)/, errorMessages.POLICY_ZIP_FORMAT)
|
||||
);
|
||||
defineRule('loss-date-gt-10-years', (value) => {
|
||||
const lossDate = new Date(Date.parse(`${value}T00:00:00`));
|
||||
const today = new Date();
|
||||
const tenYearsAgo = new Date(today.getFullYear() - 10, today.getMonth(), today.getDate(), 0, 0, 0, 0);
|
||||
if (lossDate < tenYearsAgo) {
|
||||
return errorMessages.DAMAGE_DATE_REQUIREMENT;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
export default {
|
||||
name: 'welcome-page',
|
||||
|
|
@ -248,7 +258,7 @@ export default {
|
|||
rules: {
|
||||
policyNumber: 'policy-number-required',
|
||||
policyZip: 'policy-zip-required|policy-zip-format',
|
||||
lossDate: 'loss-date-required',
|
||||
lossDate: 'loss-date-required|loss-date-gt-10-years',
|
||||
damageOption: 'damage-option-required',
|
||||
phoneNumber: `${globalRules.PHONE_NUMBER_REQUIRED}|${globalRules.PHONE_NUMBER_FORMAT}`,
|
||||
email: `${globalRules.EMAIL_ADDRESS_REQUIRED}|${globalRules.EMAIL_ADDRESS_FORMAT}`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue