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

/**
* @typedef {object} EqValidatorSettings
*
* @property {mixed} value The value to compare against.
*
* @memberof module:libresignage/ui/validator
* @alias    EqValidatorSettings
*/

/**
* Class for validating input values using strict equality.
*
* @memberof module:libresignage/ui/validator
*/
class EqValidator extends BaseValidator {
	/**
	* Construct a new EqValidator object.
	*
	* @param {EqValidatorSettings} settings
	* @param {string}              msg
	* @param {boolean}             nostyle
	*
	* @see {@link module:libresignage/ui/validator.BaseValidator} Parent class.
	*/
	constructor(...args) {
		super(...args);
		this.chk_settings(['value']);
	}

	validate(element) {
		if (typeof this.settings.value === 'function') {
			return element.value === this.settings.value();
		} else {
			return element.value === this.settings.value;
		}
	}
}
module.exports = EqValidator;
