2024-05-07 22:46:44 +02:00
|
|
|
import {Validator} from "./Validator";
|
2022-02-24 23:52:45 +01:00
|
|
|
|
2024-05-07 22:46:44 +02:00
|
|
|
export class Required extends Validator
|
2022-02-24 23:52:45 +01:00
|
|
|
{
|
2022-09-20 18:44:28 +02:00
|
|
|
/**
|
|
|
|
* Returns a Boolean. True if the test fails
|
|
|
|
* @param {?} [modelValue]
|
|
|
|
* @param {?} [param]
|
|
|
|
* @param {{}} [config]
|
|
|
|
* @returns {Boolean|Promise<Boolean>}
|
|
|
|
*/
|
|
|
|
execute(modelValue : any, param : any, config : {}) : boolean | Promise<boolean>
|
|
|
|
{
|
|
|
|
return modelValue == "" || modelValue == undefined || modelValue == null;
|
|
|
|
}
|
|
|
|
|
2022-02-24 23:52:45 +01:00
|
|
|
/**
|
|
|
|
* Give a message about this field being required. Could be customised according to MessageData.
|
|
|
|
* @param {MessageData | undefined} data
|
|
|
|
* @returns {Promise<string>}
|
|
|
|
*/
|
|
|
|
static async getMessage(data)
|
|
|
|
{
|
|
|
|
return data.formControl.egw().lang("Field must not be empty !!!");
|
|
|
|
}
|
|
|
|
}
|