/**
 * DevExtreme (esm/__internal/scheduler/options_validator/core/validator.js)
 * Version: 24.1.7-build-24272-1937
 * Build date: Sat Sep 28 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
export class Validator {
    constructor(valueSelector, rules) {
        this.valueSelector = valueSelector;
        this.rules = rules
    }
    validate(options) {
        const value = this.valueSelector(options);
        const errors = this.rules.reduce(((result, rule) => {
            const validationResult = rule(value);
            if (true !== validationResult) {
                result[rule.name] = validationResult
            }
            return result
        }), {});
        return Object.keys(errors).length ? errors : true
    }
}
