Skip to content

Commit

Permalink
Fix 400 server error by validating property names (#2731)
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr authored Jan 27, 2023
1 parent 100c92b commit 69e24d8
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions source/frontend/src/features/leases/add/AddLeaseYupSchema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-template-curly-in-string */
import * as Yup from 'yup';

import { isLeaseCategoryVisible } from './AdministrationSubForm';
Expand All @@ -9,12 +10,12 @@ export const AddLeaseYupSchema = Yup.object().shape({
paymentReceivableTypeCode: Yup.string().required('Payment Receivable Type is required'),
regionId: Yup.string().required('MOTI Region Type is required'),
programTypeCode: Yup.string().required('Program Type is required'),
motiName: Yup.string().max(200, 'MOTI Contact must be at most 200 characters'),
motiName: Yup.string().max(200, 'MOTI Contact must be at most ${max} characters'),
otherProgramTypeDescription: Yup.string().when('programTypeCode', {
is: (programTypeCode: string) => programTypeCode && programTypeCode === 'OTHER',
then: Yup.string()
.required('Other Description required')
.max(200, 'Other Description must be at most 200 characters'),
.max(200, 'Other Description must be at most ${max} characters'),
otherwise: Yup.string().nullable(),
}),
leaseTypeCode: Yup.string().required('Lease Type is required'),
Expand All @@ -24,7 +25,7 @@ export const AddLeaseYupSchema = Yup.object().shape({
is: (leaseTypeCode: string) => leaseTypeCode && leaseTypeCode === 'OTHER',
then: Yup.string()
.required('Other Description required')
.max(200, 'Other Description must be at most 200 characters'),
.max(200, 'Other Description must be at most ${max} characters'),
otherwise: Yup.string().nullable(),
}),
categoryTypeCode: Yup.string()
Expand All @@ -39,23 +40,28 @@ export const AddLeaseYupSchema = Yup.object().shape({
is: (categoryTypeCode: string) => categoryTypeCode && categoryTypeCode === 'OTHER',
then: Yup.string()
.required('Other Description required')
.max(200, 'Other Description must be at most 200 characters'),
.max(200, 'Other Description must be at most ${max} characters'),
otherwise: Yup.string().nullable(),
}),
purposeTypeCode: Yup.string().required('Purpose Type is required'),
otherPurposeTypeDescription: Yup.string().when('purposeTypeCode', {
is: (purposeTypeCode: string) => purposeTypeCode && purposeTypeCode === 'OTHER',
then: Yup.string()
.required('Other Description required')
.max(200, 'Other Description must be at most 200 characters'),
.max(200, 'Other Description must be at most ${max} characters'),
otherwise: Yup.string().nullable(),
}),
documentationReference: Yup.string().max(
500,
'Location of documents must be at most 500 characters',
'Location of documents must be at most ${max} characters',
),
description: Yup.string().max(4000, 'Description must be at most ${max} characters'),
note: Yup.string().max(4000, 'Notes must be at most ${max} characters'),
tfaFileNumber: Yup.string().max(50, 'LIS # must be at most ${max} characters'),
psFileNo: Yup.string().max(50, 'PS # must be at most ${max} characters'),
properties: Yup.array().of(
Yup.object().shape({
name: Yup.string().max(250, 'Property name must be at most ${max} characters'),
}),
),
description: Yup.string().max(4000, 'Description must be at most 4000 characters'),
note: Yup.string().max(4000, 'Notes must be at most 4000 characters'),
tfaFileNumber: Yup.string().max(50, `LIS # must be at most 50 characters`),
psFileNo: Yup.string().max(50, 'PS # must be at most 50 characters'),
});

0 comments on commit 69e24d8

Please sign in to comment.