@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
14 lines • 453 B
JavaScript
export var toErrors = function toErrors(errorMessages) {
// Check to see if toErrors was already applied to errorMessages
// this flexibility allows for more consistent utility functions
var firstValue = errorMessages[0];
if (firstValue && firstValue.type === 'error' && typeof firstValue.text === 'string') {
return errorMessages;
}
return errorMessages.map(function (e) {
return {
text: e,
type: 'error'
};
});
};