Skip to content

Support for class based validators  #197

@bobisjan

Description

@bobisjan

Hello 👋,

I have question about using class based validators.

The use case is about having validator dependent on a service.

import Validator from 'ember-changeset-validations/validator';
import  { inject as service } from '@ember/service';

export default class PersonalNoValidator extends Validator {
  @service ajax;

  async validate(key, newValue, oldValue, changes, content) {
    try {
      await this.ajax.post('/api/personal-no/validation', { data: newValue });
      return true;
    } catch (_) {
      return 'Personal No is invalid';
    }
  }
}

Would it make sense to support this, or is there a path to solve this currently?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions