Aurelia validation - notation (res :Class) => res.property

Hello,
i follow manual : Validation | Aurelia
and in section multiple validation controllers is used notation:
(res: ItalianRestaurant) => res.pizza

const pizzaRules = ValidationRules
.ensure((res: ItalianRestaurant) => res.pizza).required()
.rules;

in my new fresh app (Es2015, babel, cli, webpack )
i cant use this notation . I 've got error:

Module build failed: SyntaxError: Unexpected token, expected ,

generally speaking where is a problem ? :slight_smile:

btw. when i use direct property validation like this:

ValidationRules.ensure(this.institution.user.password).required().rules;
validation “work” and i got error but when field is not empty i still got error ?
it’s weired

if you are using babel as transpiler, it means you are writing code in ESNext not in TypeScript, so res: ItalianRestaurant should not be a valid syntax since JS do not allow us to explicitly tell the data type.

try:

const pizzaRules = ValidationRules
.ensure(res => res.pizza).required()
.rules;

@lyrog please ensure you have dependencies updated
there is currently an investigation of issue with npm updating the dependencies

latest aurelia-validation requires aurelia-binding: ^1.7.1

seems like npm ugrade does not do the right job

Tahnks.
You are right. There is mistake in mentioned documentation.

It was long fight :slight_smile: but at least i find out, if I need to validate property of nested class i nedd to use special syntax :
for this.institution.user.email
i nedd to use validation like that

ValidationRules
.ensure(‘email’).email().required()
.on(User);