// @flow strict export const RATING_ERRORS = Object.freeze({ INVALID_RANGE: { type: 'INVALID_RANGE', description: 'Given rating\'s stop value cannot come before the start value.', }, INVALID_RATING_LABELS: { type: 'INVALID_RATING_LABELS', description: 'Given rating labels are invalid.', }, }); export const RATINGS: Array = [ 'Not-Qualified', 'Proficient', 'Silver', 'Gold', 'Platinum', 'Diamond', ]; export const getRatingLabel = ( rating: number, labels: Array, ): string => { if (rating <= 0) { return labels[0]; } else if (rating >= labels.length) { return labels.slice(-1)[0]; } else { return labels[rating]; } };