Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static columnValuesForFeature(feature, options = {}) {
const values = {};
for (const formValue of feature.formValues.all) {
if (formValue.isEmpty) {
continue;
}
const element = formValue.element;
let columnValue = formValue.columnValue;
if (_.isNumber(columnValue) || _.isString(columnValue) || _.isArray(columnValue) || _.isDate(columnValue)) {
if (options.calculatedFieldDateFormat === 'date' && element.isCalculatedElement && element.display.isDate) {
columnValue = DateUtils.parseDate(formValue.textValue);
}
// don't allow dates greater than 9999, yes - they exist in the wild
if (_.isDate(columnValue)) {
columnValue = columnValue.getFullYear() > 9999 ? null : formValue.textValue;
}
this.maybeAssignArray(values, 'f' + formValue.element.key.toLowerCase(), columnValue, options.disableArrays, options.disableComplexTypes);
} else if (columnValue) {
if (element && options.mediaURLFormatter) {
if (element.isPhotoElement || element.isVideoElement || element.isAudioElement) {
const prefix = 'f' + formValue.element.key.toLowerCase();
columnValue[prefix + '_urls'] = options.mediaURLFormatter(formValue);