@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
15 lines (14 loc) • 482 B
JavaScript
export var toErrors = function(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'
};
});
};