aurelia / validatejs

Enables expressive validation using decorators and/or a fluent API.
MIT License
22 stars 23 forks source link

Error when trying to validate in custom element #49

Closed stevies closed 8 years ago

stevies commented 8 years ago

I tried creating a custom element to generate a validated input box.

<template bindable="property">
    <label>${label}</label>
    <input type="text" value.two-way="property">
</template>

Include it in a main view like this:

  <validated-input label="Name" property.two-way="person.name"></validated-input>

App fails to load with error:

Unhandled rejection TypeError: Cannot read property 'bindingContext' of null
    at ValidateBindingBehavior.getReporter (http://localhost:3000/1.bundle.js:20078:32)
    at ValidateBindingBehavior.bind (http://localhost:3000/1.bundle.js:20047:22)
    at BindingBehavior.bind (http://localhost:3000/1.bundle.js:3140:20)
    at Binding.bind (http://localhost:3000/1.bundle.js:6630:30)
    at View.bind (http://localhost:3000/1.bundle.js:8251:20)
    at Controller.bind (http://localhost:3000/1.bundle.js:10238:18)
    at View.bind (http://localhost:3000/1.bundle.js:8261:23)
    at Controller.bind (http://localhost:3000/1.bundle.js:10238:18)
    at Controller.automate (http://localhost:3000/1.bundle.js:10184:11)
    at http://localhost:3000/1.bundle.js:11212:19
    at tryCatcher (http://localhost:3000/bundle.js:13605:24)
    at Promise._settlePromiseFromHandler (http://localhost:3000/bundle.js:11636:32)
    at Promise._settlePromise (http://localhost:3000/bundle.js:11693:19)
    at Promise._settlePromise0 (http://localhost:3000/bundle.js:11738:11)
    at Promise._settlePromises (http://localhost:3000/bundle.js:11817:19)
    at Async._drainQueue (http://localhost:3000/bundle.js:8697:17)

Custom element works OK (without the validation) if I remove the & validate:

 <input type="text" value.two-way="property">
plwalters commented 8 years ago

This is noted in instructions because right now we infer the reporter from the context. Tracking here - https://github.com/aurelia/validatejs/issues/25