adopted-ember-addons / adopted-ember-addons/ember-cp-validations

hasValidations decorator ES6/TypeScript

Open
#603 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
439
Forks
172
PR merge metrics
No merged PRs in 30d

Description

I'm trying to use cp-validations within an app using ES6 classes & TypeScript and I'm getting a few errors.

Here is what my component looks like:

```ts
import Component from '@ember/component';
import {
validator,
buildValidations,
hasValidations
} from 'ember-cp-validations';

const Validations = buildValidations({
identification: [
validator('presence', true),
validator('format', { type: 'email' })
],

password: [
validator('presence', true),
validator('length', {
min: 8
})
]
});

@hasValidations(Validations)
export default class LoginForm extends Component.extend({
// ....
}) {
identification: string = '';
password: string = '';
}
```

The first problem that I get is when running tests for this component, the error I get is:

```
Error: Assertion Failed: You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update to call `this._super(...arguments);` from `init`.@ 196 ms
```

This error only appears in tests, but not when running the app.

Note: Using `Component.extend` does not work, so I have to use the decorator.

### Environment

- Ember Version: 3.3.1
- Ember CLI Version: 3.3.0
- Ember CP Validations Version: 4.0.0-beta.2

### Steps to Reproduce

https://github.com/josemarluedke/--ember-cp-validations-repro

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.