joyce/src/modules/validation.js

27 lines
705 B
JavaScript
Raw Normal View History

2018-11-23 21:23:08 +00:00
import regex from './regex'
2018-11-30 07:37:36 +00:00
export const validateSubmittedDocument = (docType, inputs) => {
2018-11-23 21:23:08 +00:00
const errors = []
if (docType === 'tags') {
2018-11-30 07:37:36 +00:00
if (inputs.colorPicker.length < 1) {
2018-11-23 21:23:08 +00:00
errors.push('Please select a tag color.')
2018-11-30 07:37:36 +00:00
} else if (!regex.checkColorPickerHexValue(inputs.colorPicker)) {
2018-11-23 21:23:08 +00:00
errors.push('Please select a valid hex code color.')
}
}
2018-11-30 07:37:36 +00:00
if (inputs.documentTitle.length < 1) {
2018-11-23 21:23:08 +00:00
errors.push('Please enter a title.')
}
return errors
2018-11-24 01:18:42 +00:00
}
export const validateSubmittedAnnotation = (annotationNote, annotationTag) => {
const errors = []
if (!annotationNote.id) {
errors.push('Please choose a note.')
}
if (!annotationTag.id) {
errors.push('Please choose a tag.')
}
return errors
2018-11-23 21:23:08 +00:00
}