var BaseValidator = require('libresignage/ui/validator/BaseValidator');

/**
* @typedef {object} WhitelistValidatorSettings
*
* @property {array} wl The whitelist to use.
*
* @memberof module:libresignage/ui/validator
* @alias    WhitelistValidatorSettings
*/

/**
* Class for validating inputs against a whitelist.
*
* @memberof module:libresignage/ui/validator
*/
class WhitelistValidator extends BaseValidator {
	/**
	* Construct a new WhitelistValidator object.
	*
	* @param {WhitelistValidatorSettings} settings
	* @param {string}                     msg
	* @param {boolean}                    nostyle
	*
	* @see {@link module:libresignage/ui/validator.BaseValidator} Parent class.
	*/
	constructor(...args) {
		super(...args);
		this.chk_settings(['wl']);
	}

	validate(element) {
		return this.settings.wl.includes(element.value);
	}
}
module.exports = WhitelistValidator;
