add aliases validation

This commit is contained in:
guiyomu-dev
2026-01-29 07:19:53 +01:00
parent 4d9c6e75cd
commit d0987cb9e9
2 changed files with 14 additions and 0 deletions

View File

@@ -63,6 +63,10 @@ func ParseNIPFile(filePath string) (Rules, error) {
return nil, fmt.Errorf("error reading %s file at line %d: %w", filePath, lineNumber, err)
}
if err := rule.ValidateStats(); err != nil {
return nil, fmt.Errorf("error validating rule on [%s:%d]: %w", filePath, lineNumber, err)
}
// We evaluate all the rules at startup to ensure no format errors, if there is a format error we will throw it now instead of during runtime
_, err = rule.Evaluate(dummyItem)
if err != nil {

View File

@@ -488,6 +488,16 @@ func getRequiredStatsForRule(line string) []string {
return statsList
}
// ValidateStats checks that all required stats in stage2 are valid aliases.
func (r Rule) ValidateStats() error {
for _, statName := range r.requiredStats {
if _, found := statAliases[statName]; !found {
return fmt.Errorf("property %s is not valid or not supported", statName)
}
}
return nil
}
func evaluateClassSkillsSum(it data.Item) int {
// Check all class skills stats
totalClassSkills := 0