According to the official docs,
"The validation controller has a subscribe(callback: (event: ValidateEvent) => void) method you can use to subscribe to validate and reset events. ".
I try to do this.myValidationController.subscribe()
but I get an error saying "this.validationController.subscribe is not a function
". Any idea why that is?
this.validator.validateObject(this.todo)
is being used... is this the path i need to go down?
changeOrBlur
. We have a set of validation rules on our model (Manufacturing Orders). We then have a separate view-model that is used to create new Manufacturing orders. I am running into problems when setting the installation date from an date-picker custom attribute. When the user selects a date it blurs the input box causing the UI to throw an error that Installation Date is Required
. The only way to clear this error is to reselect a date or to click in and out of the date input box.
const controller1Rules = ValidationRules
.ensure('addNewRacfId').required().withMessage('User Id is required').minLength(8).withMessage('User Id must at least be 8 characters long.')
.rules;
const racfIdValidated = () => {
return this.addNewUserRacfFilter();
};
.ensureObject().satisfies(racfIdValidated)
const racfIdValidated = () => {
return false;
};
const racfRules = ValidationRules
.ensure('addNewRacfId').required()
.ensureObject().satisfies(racfIdValidated).withMessage('user not found').rules;
this.racfValidationController.addObject(this, racfRules);
Hi guys, when running this validation i am trying to add a custom rule
the required is triggering...
i am tryinng to pass false in racfIdValidated custom rule
but it is still not showing the custom message of user not found
const racfIdValidated = () => {
console.log('hello world')
return false;
};
const racfRules = ValidationRules
.ensure('addNewRacfId').required()
.then().satisfies(racfIdValidated).withMessage('user not found').rules;
hi! i have a question how to make a validation rules with objects which contains nested objects because i always get an error when the rules get parsed:
export class PartnerItemViewModel {
id: number;
name1: string;
name2: string;
address: AddressViewModel;
}
export class AddressViewModel{
id: number;
street: string;
houseNo: string;
location: string;
zipCode: string;
countryCode: string;
}
ValidationRules
.ensure((p: PartnerItemViewModel) => p.name1)
.required().withMessageKey('please_enter')
.ensure((p: PartnerItemViewModel) => p.name2)
.required().withMessageKey('please_enter')
.ensureObject().satisfies(p => p.address).withMessageKey('please_enter')
.required().withMessageKey('please_enter')
.then()
.ensure((p: PartnerItemViewModel) => p.address.street)
.required().withMessageKey('please_enter')
.on(this)
.rules;
the error is
Message: Unable to parse accessor function:
function (p) { return p.address.street; }
ValidationRules.ensure(this.movie.title).required();
}
Hello all. Does anyone know how to use validation on generated inputs inside repeat.for? I would like to validate dynamic form based on Arrays and Maps.
Examples:
<div repeat.for="double of doubles"> <!-- doubles is an array -->
<input placeholder="double ${$index + 1}" value.bind="double & validate">
</div>
<div repeat.for="[key,value] of stringDoubleMap"> <!-- stringDoubleMap is a map -->
<input placeholder="${key}" value.bind="value $ validate">
</div>
I need to use similar form to generate XML in output. I would like to validate each generated input separatly.
hi! i have a question how to make a validation rules with objects which contains nested objects because i always get an error when the rules get parsed:
export class PartnerItemViewModel {
id: number;
name1: string;
name2: string;
address: AddressViewModel;
}
export class AddressViewModel{
id: number;
street: string;
houseNo: string;
location: string;
zipCode: string;
countryCode: string;
}
ValidationRules
.ensure((p: PartnerItemViewModel) => p.name1)
.required().withMessageKey('please_enter')
.ensure((p: PartnerItemViewModel) => p.name2)
.required().withMessageKey('please_enter')
.ensureObject().satisfies(p => p.address).withMessageKey('please_enter')
.required().withMessageKey('please_enter')
.then()
.ensure((p: PartnerItemViewModel) => p.address.street)
.required().withMessageKey('please_enter')
.on(this)
.rules;
the error is
Message: Unable to parse accessor function:
function (p) { return p.address.street; }
I'm having exactly the same issue. I prefer to keep my form bindings in a model as well, but the accessor function fails every time, forcing me to move the properties outside of a model. That is a solution, I guess, but shouldn't there be a simple way of doing this?