samedi 18 janvier 2020

ember-changeset-validations not validating properly

I'm on Ember 3.15 (Octane) and trying to get ember-changeset-validations working by following the examples on their github but having a hard time getting it to validate. There are no (code related) errors in the console but changeset.isValid always returns true.


import {action} from "@ember/object";
import MyValidationClass from '../Validations/myValidations';

export default class MyController extends Controller {
  MyValidationClass;

  @action
  submit(changeset) { 
    changeset.save()
  }
}

--


<MyComponent
  @changeset=
  @onSubmit=
/>

--


export default class MyComponent extends Component {
    async submit(changeset) {
      await changeset.validate();
      console.log(changeset.isValid);   // returns true even when the validation should fail
    }
}

--


import {
  validateLength,
  validatePresence
} from 'ember-changeset-validations/validators';

export default {
  title: [
    validatePresence(true),
    validateLength({ min: 44 })
  ]
};



Aucun commentaire:

Enregistrer un commentaire