lion/packages/ui/components/combobox/src/validators.js
gerjanvangeest a2b81b2693
feat(combobox): add requireOptionMatch flag and MatchesOption validator
Co-authored-by: Thijs Louisse <thijs.louisse@ing.com>
2023-03-16 18:18:40 +01:00

18 lines
494 B
JavaScript

/* eslint-disable max-classes-per-file */
import { Unparseable, Validator } from '@lion/ui/form-core.js';
export class MatchesOption extends Validator {
static get validatorName() {
return 'MatchesOption';
}
/**
* @param {unknown} [value]
* @param {string | undefined} [options]
* @param {{ node: any }} [config]
*/
// eslint-disable-next-line class-methods-use-this
execute(value, options, config) {
return config?.node.modelValue instanceof Unparseable;
}
}