I can't get Aurelia-Validate to work on the fields in my calendar record.
calendar.html (excerpt)
<form>
<div class="form-group">
<label class="control-label" for="cal_name_orig">Calendar name</label>
<input type="text" class="form-control" id="cal_name_orig" value.bind="calendar.cal_name_orig & validate">
</div>
<div class="form-group">
<label class="control-label" for="cal_name_tran">Translated name</label>
<input type="text" class="form-control" id="cal_name_tran" value.bind="calendar.cal_name_tran & validate">
</div>
</form>
calendars.js (simplified):
import { inject, NewInstance } from 'aurelia-dependency-injection';
import { ValidationController, ValidationRules } from 'aurelia-validation';
import { BootstrapFormRenderer } from '../../common/bootstrap-form-renderer';
@inject(NewInstance.of(ValidationController))
export class CalendarForm {
controller = null;
constructor(controller) {
this.controller = controller;
this.controller.addRenderer(new BootstrapFormRenderer());
this.calendar = {
cal_name_orig = "",
cal_name_tran = ""
}
}
validateCalendar() {
let v = this.controller.validate();
console.log(v);
}
}
ValidationRules
.ensure('calendar.cal_name_orig').required().minLength(5).maxLength(20)
.ensure('calendar.cal_name_tran').minLength(5).maxLength(20)
.on(CalendarForm);
If I change value.bind="calendar.cal_name_orig & validate"
to value.bind="cal_name_orig & validate"
and .ensure('calendar.cal_name_orig')
to .ensure('cal_name_orig')
, the validation works and renders on the form (but the data doesn't bind to the right part of the data in this class.
How can I get Aurelia Validate to recognize calendar.cal_name_orig?