import { MappingUser } from '../../../mapping/user';
import { baseValidityFlagNames, RichTextMentionValidator } from '../../base/models/mention-validator';
const usersValidityFlagNames = [
    ...baseValidityFlagNames,
    'missingDisplayNameValue',
    'unsupportedMappingType'
];
/**
 * Validator for RichTextMentionUsers
 */
export class RichTextMentionUsersValidator extends RichTextMentionValidator {
    constructor() {
        super(usersValidityFlagNames);
    }
    static isSupportedMappingElement(mapping) {
        return mapping instanceof MappingUser;
    }
    validate(mappings, pattern) {
        super.validate(mappings, pattern);
        this.validateMappingTypes(mappings);
        this.validateNoMissingDisplayName(mappings);
    }
    validateNoMissingDisplayName(mappings) {
        const invalid = mappings.some(mapping => mapping.displayName === undefined);
        this.setConditionValue('missingDisplayNameValue', invalid);
    }
    validateMappingTypes(mappings) {
        const valid = mappings.every(RichTextMentionUsersValidator.isSupportedMappingElement);
        this.setConditionValue('unsupportedMappingType', !valid);
    }
}
//# sourceMappingURL=rich-text-mention-users-validator.js.map