Currently, I am developing aurelia-validation and encountering an issue with the on
method from a different overload (FluentRuleCustomizer
) class. The code works fine when using ruleBuilder['on'](field);
, however, changing it to ruleBuilder.on(field);
results in a red squiggly line under ruleBuilder.on(field);
. Please refer to the code snippet and screenshot below.
import { ValidationRules, FluentRuleCustomizer, FluentEnsure, FluentRules } from 'aurelia-validation';
import { on } from 'cluster';
export class FormHelper {
private static initializedForms = [];
public static initializeFormRules(form) {
if (this.initializedForms.indexOf(form) > -1) {
return;
}
this.initializedForms.push(form);
for (const field of form.fields) {
if (field.validation.isValidate) {
let ruleBuilder: | FluentRules<any, any> | FluentEnsure<any> | FluentRuleCustomizer<any, any>;
ruleBuilder = ValidationRules
.ensure("value")
.displayName(field.label);
const rules = Object.keys(field.validation.validationRule)
.map(key => ({ key, value: field.validation.validationRule[key] }));
for (const rule of rules) {
ruleBuilder = ruleBuilder[rule.key](rule.value);
}
// ruleBuilder['on'](field);
ruleBuilder.on(field);
}
}
}
}
Here is the link to all the exported classes available for aurelia-validation
.
Your assistance will be greatly appreciated :)