Skip to content

Commit

Permalink
More section validations
Browse files Browse the repository at this point in the history
  • Loading branch information
Sominemo committed Jan 9, 2025
1 parent bc87cc0 commit efa7358
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,22 @@ <h1>Telegram Limits Editor</h1>
const structureSection = this.structure.find(section => section.id === sectionId);
const localizationSection = this.localization[sectionId];

if (!localizationSection.name) {
throw new ValidationError(`Section name is empty for section ${sectionId}`, true);
}

if (!structureSection.color) {
throw new ValidationError(`Section color is empty for section ${sectionId}`, true);
}

if (!structureSection.icon) {
throw new ValidationError(`Section icon is empty for section ${sectionId}`, true);
}

if (!this.iconCodePoints[structureSection.icon]) {
throw new ValidationError(`Icon ${structureSection.icon} is not found in the icon code points map for section ${sectionId}`, true);
}

const rgbRegex = /^(\d{1,3}), (\d{1,3}), (\d{1,3})$/;

const match = structureSection.color.match(rgbRegex);
Expand Down Expand Up @@ -846,11 +862,11 @@ <h1>Telegram Limits Editor</h1>
const iconName = item.icon;

if (iconName.length === 0) {
throw new ValidationError(`Icon name is empty for item ${item.id} in section ${sectionId}`);
throw new ValidationError(`Icon name is empty for item ${item.id} in section ${sectionId}`, true);
}

if (!this.iconCodePoints[iconName]) {
throw new ValidationError(`Icon ${iconName} is not found in the icon code points map for item ${item.id} in section ${sectionId}`);
throw new ValidationError(`Icon ${iconName} is not found in the icon code points map for item ${item.id} in section ${sectionId}`, true);
}
}
}
Expand Down

0 comments on commit efa7358

Please sign in to comment.