department-of-veterans-affairs/vets-website

View on GitHub
src/applications/disability-benefits/all-claims/migrations/05-truncate-otherAtRiskHousing.js

Summary

Maintainability
A
2 hrs
Test Coverage
import omit from 'platform/utilities/data/omit';

import { MAX_HOUSING_STRING_LENGTH } from '../constants';

export default savedData => {
  if (savedData.formData.otherAtRiskHousing) {
    const formData = omit('otherAtRiskHousing', savedData.formData);
    formData.otherAtRiskHousing = savedData.formData.otherAtRiskHousing.substring(
      0,
      MAX_HOUSING_STRING_LENGTH,
    );
    return {
      formData,
      metadata: savedData.metadata,
    };
  }
  return savedData;
};