add aliases validation
This commit is contained in:
@@ -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)
|
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
|
// 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)
|
_, err = rule.Evaluate(dummyItem)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -488,6 +488,16 @@ func getRequiredStatsForRule(line string) []string {
|
|||||||
return statsList
|
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 {
|
func evaluateClassSkillsSum(it data.Item) int {
|
||||||
// Check all class skills stats
|
// Check all class skills stats
|
||||||
totalClassSkills := 0
|
totalClassSkills := 0
|
||||||
|
|||||||
Reference in New Issue
Block a user