lion/packages/form-core/test-helpers/ExampleValidators.js
Joren Broekema 874ff48339 feat(form-core): form-core types
Co-authored-by: Thijs Louisse <Thijs.Louisse@ing.com>
2020-09-02 09:02:47 +02:00

53 lines
920 B
JavaScript

/* eslint-disable max-classes-per-file, class-methods-use-this */
import { Validator } from '../src/validate/Validator.js';
export class AlwaysInvalid extends Validator {
static get validatorName() {
return 'AlwaysInvalid';
}
execute() {
const showMessage = true;
return showMessage;
}
}
export class AlwaysValid extends Validator {
static get validatorName() {
return 'AlwaysValid';
}
/**
* @return {Promise<boolean> | boolean}
*/
execute() {
const showMessage = false;
return showMessage;
}
}
export class AsyncAlwaysValid extends AlwaysValid {
static get async() {
return true;
}
/**
* @return {Promise<boolean>}
*/
async execute() {
return true;
}
}
export class AsyncAlwaysInvalid extends AlwaysValid {
static get async() {
return true;
}
/**
* @return {Promise<boolean>}
*/
async execute() {
return false;
}
}