Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

18788 Updated NameRequestMixin #224

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/mixins/name-request-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Vue from 'vue'
import { Component } from 'vue-property-decorator'
import { NameRequestStates, NrRequestActionCodes } from '@bcrs-shared-components/enums'
import { NameRequestIF } from '@bcrs-shared-components/interfaces'
import { CorpTypeCd } from '@/modules/corp-type-module'

/**
* Mixin that provides some useful Name Request utilities.
Expand All @@ -16,21 +17,24 @@ export default class NameRequestMixin extends Vue {
* @param businessId the business identifier to match
* @param phone the applicant's phone number to match
* @param email the applicant's email address to match
* @param legalType the business legal type to match
* @returns the name request object
*/
validateNameRequest (
nameRequest: NameRequestIF,
nrRequestActionCode: NrRequestActionCodes,
businessId?: string,
phone?: string,
email?: string
email?: string,
legalType?: CorpTypeCd
): NameRequestIF {
// ensure NR is valid
const invalid = this.isNrInvalid(nameRequest)
if (invalid) {
throw new Error(`Invalid Name Request: ${invalid}`)
}

// match action code
if (nameRequest.request_action_cd !== nrRequestActionCode) {
throw new Error('Incorrect Request Action Code')
}
Expand All @@ -50,6 +54,11 @@ export default class NameRequestMixin extends Vue {
throw new Error('Incorrect Phone Number')
}

// match legal type
if (legalType && nameRequest.legalType !== legalType) {
throw new Error('Incorrect Legal Type')
}

// ensure NR is consumable
const state = this.getNrState(nameRequest)
if (state !== NameRequestStates.APPROVED && state !== NameRequestStates.CONDITIONAL) {
Expand Down
Loading