Skip to content

Commit

Permalink
Merge pull request #68 from chuff/remove-validation
Browse files Browse the repository at this point in the history
remove validation
  • Loading branch information
aitnitishshelage authored Dec 19, 2024
2 parents 9a4a7fd + ea6688f commit 0cd7ef3
Show file tree
Hide file tree
Showing 21 changed files with 7 additions and 3,302 deletions.
7 changes: 7 additions & 0 deletions modules/cmpapi/src/encoder/GppModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ export class GppModel {
}

public decodeSection(sectionName: string, encodedString: string): void {
if (!this.decoded) {
this.sections = this.decodeModel(this.encodedString);
this.dirty = false;
this.decoded = true;
}

let section: EncodableSection = null;
if (!this.sections.has(sectionName)) {
if (sectionName === TcfCaV1.NAME) {
Expand Down Expand Up @@ -439,6 +445,7 @@ export class GppModel {

if (section) {
section.decode(encodedString);
this.dirty = true;
}
}

Expand Down
133 changes: 0 additions & 133 deletions modules/cmpapi/src/encoder/segment/UsCaCoreSegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,137 +124,4 @@ export class UsCaCoreSegment extends AbstractLazilyEncodableSegment<EncodableBit
throw new DecodingError("Unable to decode UsCaCoreSegment '" + encodedString + "'");
}
}

// overriden
public validate(): void {
let sharingOptOutNotice: number = this.fields.get(UsCaField.SHARING_OPT_OUT_NOTICE).getValue();
let sharingOptOut: number = this.fields.get(UsCaField.SHARING_OPT_OUT).getValue();
let saleOptOutNotice: number = this.fields.get(UsCaField.SALE_OPT_OUT_NOTICE).getValue();
let saleOptOut: number = this.fields.get(UsCaField.SALE_OPT_OUT).getValue();
let mspaServiceProviderMode: number = this.fields.get(UsCaField.MSPA_SERVICE_PROVIDER_MODE).getValue();
let mspaOptOutOptionMode: number = this.fields.get(UsCaField.MSPA_OPT_OUT_OPTION_MODE).getValue();
let sensitiveDataLimtUserNotice: number = this.fields.get(UsCaField.SENSITIVE_DATA_LIMIT_USE_NOTICE).getValue();

if (sharingOptOutNotice == 0) {
if (sharingOptOut != 0) {
throw new ValidationError(
"Invalid usca sharing notice / opt out combination: {" + sharingOptOutNotice + " / " + sharingOptOut + "}"
);
}
} else if (sharingOptOutNotice == 1) {
if (sharingOptOut != 1 && sharingOptOut != 2) {
throw new ValidationError(
"Invalid usca sharing notice / opt out combination: {" + sharingOptOutNotice + " / " + sharingOptOut + "}"
);
}
} else if (sharingOptOutNotice == 2) {
if (sharingOptOut != 1) {
throw new ValidationError(
"Invalid usca sharing notice / opt out combination: {" + sharingOptOutNotice + " / " + sharingOptOut + "}"
);
}
}

if (saleOptOutNotice == 0) {
if (saleOptOut != 0) {
throw new ValidationError(
"Invalid usca sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}"
);
}
} else if (saleOptOutNotice == 1) {
if (saleOptOut != 1 && saleOptOut != 2) {
throw new ValidationError(
"Invalid usca sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}"
);
}
} else if (saleOptOutNotice == 2) {
if (saleOptOut != 1) {
throw new ValidationError(
"Invalid usca sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}"
);
}
}

if (mspaServiceProviderMode == 0) {
if (saleOptOutNotice != 0) {
throw new ValidationError(
"Invalid usca mspa service provider mode / sale opt out notice combination: {" +
mspaServiceProviderMode +
" / " +
saleOptOutNotice +
"}"
);
}

if (sharingOptOutNotice != 0) {
throw new ValidationError(
"Invalid usca mspa service provider mode / sharing opt out notice combination: {" +
mspaServiceProviderMode +
" / " +
sharingOptOutNotice +
"}"
);
}

if (sensitiveDataLimtUserNotice != 0) {
throw new ValidationError(
"Invalid usca mspa service provider mode / sensitive data limit use notice combination: {" +
mspaServiceProviderMode +
" / " +
sensitiveDataLimtUserNotice +
"}"
);
}
} else if (mspaServiceProviderMode == 1) {
if (mspaOptOutOptionMode != 2) {
throw new ValidationError(
"Invalid usca mspa service provider / opt out option modes combination: {" +
mspaServiceProviderMode +
" / " +
mspaServiceProviderMode +
"}"
);
}

if (saleOptOutNotice != 0) {
throw new ValidationError(
"Invalid usca mspa service provider mode / sale opt out notice combination: {" +
mspaServiceProviderMode +
" / " +
saleOptOutNotice +
"}"
);
}

if (sharingOptOutNotice != 0) {
throw new ValidationError(
"Invalid usca mspa service provider mode / sharing opt out notice combination: {" +
mspaServiceProviderMode +
" / " +
sharingOptOutNotice +
"}"
);
}

if (sensitiveDataLimtUserNotice != 0) {
throw new ValidationError(
"Invalid usca mspa service provider mode / sensitive data limit use notice combination: {" +
mspaServiceProviderMode +
" / " +
sensitiveDataLimtUserNotice +
"}"
);
}
} else if (mspaServiceProviderMode == 2) {
if (mspaOptOutOptionMode != 1) {
throw new ValidationError(
"Invalid usca mspa service provider / opt out option modes combination: {" +
mspaServiceProviderMode +
" / " +
mspaOptOutOptionMode +
"}"
);
}
}
}
}
106 changes: 0 additions & 106 deletions modules/cmpapi/src/encoder/segment/UsCoCoreSegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,110 +117,4 @@ export class UsCoCoreSegment extends AbstractLazilyEncodableSegment<EncodableBit
throw new DecodingError("Unable to decode UsCoCoreSegment '" + encodedString + "'");
}
}

// overriden
public validate(): void {
let saleOptOutNotice: number = this.fields.get(UsCoField.SALE_OPT_OUT_NOTICE).getValue();
let saleOptOut: number = this.fields.get(UsCoField.SALE_OPT_OUT).getValue();
let targetedAdvertisingOptOutNotice: number = this.fields
.get(UsCoField.TARGETED_ADVERTISING_OPT_OUT_NOTICE)
.getValue();
let targetedAdvertisingOptOut: number = this.fields.get(UsCoField.TARGETED_ADVERTISING_OPT_OUT).getValue();
let mspaServiceProviderMode: number = this.fields.get(UsCoField.MSPA_SERVICE_PROVIDER_MODE).getValue();
let mspaOptOutOptionMode: number = this.fields.get(UsCoField.MSPA_OPT_OUT_OPTION_MODE).getValue();

if (saleOptOutNotice == 0) {
if (saleOptOut != 0) {
throw new ValidationError(
"Invalid usco sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}"
);
}
} else if (saleOptOutNotice == 1) {
if (saleOptOut != 1 && saleOptOut != 2) {
throw new ValidationError(
"Invalid usco sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}"
);
}
} else if (saleOptOutNotice == 2) {
if (saleOptOut != 1) {
throw new ValidationError(
"Invalid usco sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}"
);
}
}

if (targetedAdvertisingOptOutNotice == 0) {
if (targetedAdvertisingOptOut != 0) {
throw new ValidationError(
"Invalid usco targeted advertising notice / opt out combination: {" +
targetedAdvertisingOptOutNotice +
" / " +
targetedAdvertisingOptOut +
"}"
);
}
} else if (targetedAdvertisingOptOutNotice == 1) {
if (saleOptOut != 1 && saleOptOut != 2) {
throw new ValidationError(
"Invalid usco targeted advertising notice / opt out combination: {" +
targetedAdvertisingOptOutNotice +
" / " +
targetedAdvertisingOptOut +
"}"
);
}
} else if (targetedAdvertisingOptOutNotice == 2) {
if (saleOptOut != 1) {
throw new ValidationError(
"Invalid usco targeted advertising notice / opt out combination: {" +
targetedAdvertisingOptOutNotice +
" / " +
targetedAdvertisingOptOut +
"}"
);
}
}

if (mspaServiceProviderMode == 0) {
if (saleOptOutNotice != 0) {
throw new ValidationError(
"Invalid usco mspa service provider mode / sale opt out notice combination: {" +
mspaServiceProviderMode +
" / " +
saleOptOutNotice +
"}"
);
}
} else if (mspaServiceProviderMode == 1) {
if (mspaOptOutOptionMode != 2) {
throw new ValidationError(
"Invalid usco mspa service provider / opt out option modes combination: {" +
mspaServiceProviderMode +
" / " +
mspaServiceProviderMode +
"}"
);
}

if (saleOptOutNotice != 0) {
throw new ValidationError(
"Invalid usco mspa service provider mode / sale opt out notice combination: {" +
mspaServiceProviderMode +
" / " +
saleOptOutNotice +
"}"
);
}
} else if (mspaServiceProviderMode == 2) {
if (mspaOptOutOptionMode != 1) {
throw new ValidationError(
"Invalid usco mspa service provider / opt out option modes combination: {" +
mspaServiceProviderMode +
" / " +
mspaOptOutOptionMode +
"}"
);
}
}
}
}
106 changes: 0 additions & 106 deletions modules/cmpapi/src/encoder/segment/UsCtCoreSegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,110 +119,4 @@ export class UsCtCoreSegment extends AbstractLazilyEncodableSegment<EncodableBit
throw new DecodingError("Unable to decode UsCtCoreSegment '" + encodedString + "'");
}
}

// overriden
public validate(): void {
let saleOptOutNotice: number = this.fields.get(UsCtField.SALE_OPT_OUT_NOTICE).getValue();
let saleOptOut: number = this.fields.get(UsCtField.SALE_OPT_OUT).getValue();
let targetedAdvertisingOptOutNotice: number = this.fields
.get(UsCtField.TARGETED_ADVERTISING_OPT_OUT_NOTICE)
.getValue();
let targetedAdvertisingOptOut: number = this.fields.get(UsCtField.TARGETED_ADVERTISING_OPT_OUT).getValue();
let mspaServiceProviderMode: number = this.fields.get(UsCtField.MSPA_SERVICE_PROVIDER_MODE).getValue();
let mspaOptOutOptionMode: number = this.fields.get(UsCtField.MSPA_OPT_OUT_OPTION_MODE).getValue();

if (saleOptOutNotice == 0) {
if (saleOptOut != 0) {
throw new ValidationError(
"Invalid usct sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}"
);
}
} else if (saleOptOutNotice == 1) {
if (saleOptOut != 1 && saleOptOut != 2) {
throw new ValidationError(
"Invalid usct sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}"
);
}
} else if (saleOptOutNotice == 2) {
if (saleOptOut != 1) {
throw new ValidationError(
"Invalid usct sale notice / opt out combination: {" + saleOptOutNotice + " / " + saleOptOut + "}"
);
}
}

if (targetedAdvertisingOptOutNotice == 0) {
if (targetedAdvertisingOptOut != 0) {
throw new ValidationError(
"Invalid usct targeted advertising notice / opt out combination: {" +
targetedAdvertisingOptOutNotice +
" / " +
targetedAdvertisingOptOut +
"}"
);
}
} else if (targetedAdvertisingOptOutNotice == 1) {
if (saleOptOut != 1 && saleOptOut != 2) {
throw new ValidationError(
"Invalid usct targeted advertising notice / opt out combination: {" +
targetedAdvertisingOptOutNotice +
" / " +
targetedAdvertisingOptOut +
"}"
);
}
} else if (targetedAdvertisingOptOutNotice == 2) {
if (saleOptOut != 1) {
throw new ValidationError(
"Invalid usct targeted advertising notice / opt out combination: {" +
targetedAdvertisingOptOutNotice +
" / " +
targetedAdvertisingOptOut +
"}"
);
}
}

if (mspaServiceProviderMode == 0) {
if (saleOptOutNotice != 0) {
throw new ValidationError(
"Invalid usct mspa service provider mode / sale opt out notice combination: {" +
mspaServiceProviderMode +
" / " +
saleOptOutNotice +
"}"
);
}
} else if (mspaServiceProviderMode == 1) {
if (mspaOptOutOptionMode != 2) {
throw new ValidationError(
"Invalid usct mspa service provider / opt out option modes combination: {" +
mspaServiceProviderMode +
" / " +
mspaServiceProviderMode +
"}"
);
}

if (saleOptOutNotice != 0) {
throw new ValidationError(
"Invalid usct mspa service provider mode / sale opt out notice combination: {" +
mspaServiceProviderMode +
" / " +
saleOptOutNotice +
"}"
);
}
} else if (mspaServiceProviderMode == 2) {
if (mspaOptOutOptionMode != 1) {
throw new ValidationError(
"Invalid usct mspa service provider / opt out option modes combination: {" +
mspaServiceProviderMode +
" / " +
mspaOptOutOptionMode +
"}"
);
}
}
}
}
Loading

0 comments on commit 0cd7ef3

Please sign in to comment.