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?
@elitemike problem is, if you fire the validate, then all the fields will appear as having an error. You could have a workaround where you use a flag controlling whether you want to validate or not. It's not perfect, but it could work.
@jsobell your solution seems exactly what we are looking for, but we still haven't figured out how to retrieve required fields from this context. Do you have any pointer or resource that could help?