diff --git a/packages/mobile/src/screens/edit-track-screen/EditTrackScreen.tsx b/packages/mobile/src/screens/edit-track-screen/EditTrackScreen.tsx index 740c2cf4abb..a268ff5ac81 100644 --- a/packages/mobile/src/screens/edit-track-screen/EditTrackScreen.tsx +++ b/packages/mobile/src/screens/edit-track-screen/EditTrackScreen.tsx @@ -37,7 +37,9 @@ const errorMessages = { previewStartZero: 'Preview must start at 0 since the track is less than 30 seconds.', bpmTooLow: `BPM less than ${MIN_BPM}`, - bpmTooHigh: `BPM greater than ${MAX_BPM}` + bpmTooHigh: `BPM greater than ${MAX_BPM}`, + isrc: "Invalid ISRC. Must be in the format 'CC-XXX-YY-NNNNN'", + iswc: "Invalid ISWC. Must be in the format 'T-34524688-1'" } const useEditTrackSchema = () => { @@ -66,7 +68,22 @@ const useEditTrackSchema = () => { stream_conditions: z.any(), duration: z.number().nullable(), preview_start_seconds: z.any(), - bpm: z.optional(z.string().nullable()) + bpm: z.optional(z.string().nullable()), + isrc: z.optional( + z + .string() + .regex( + /^[A-Z]{2}-?[A-Z\d]{3}-?\d{2}-?\d{5}$/i, + errorMessages.isrc + ) + .nullable() + ), + iswc: z.optional( + z + .string() + .regex(/^T-?\d{3}.?\d{3}.?\d{3}.?-?\d$/i, errorMessages.iswc) + .nullable() + ) }) .refine( (values) => { @@ -88,7 +105,7 @@ const useEditTrackSchema = () => { (values) => { return typeof values.genre === 'string' && !!values.genre }, - { message: errorMessages.description, path: ['genre'] } + { message: errorMessages.genre, path: ['genre'] } ) .refine( (values) => { diff --git a/packages/mobile/src/screens/edit-track-screen/screens/IsrcIswcScreen.tsx b/packages/mobile/src/screens/edit-track-screen/screens/IsrcIswcScreen.tsx index a86cfda6323..e237e8693fc 100644 --- a/packages/mobile/src/screens/edit-track-screen/screens/IsrcIswcScreen.tsx +++ b/packages/mobile/src/screens/edit-track-screen/screens/IsrcIswcScreen.tsx @@ -1,3 +1,4 @@ +import { useFormikContext } from 'formik' import { View } from 'react-native' import { IconInfo } from '@audius/harmony-native' @@ -5,6 +6,8 @@ import { TextField } from 'app/components/fields' import { FormScreen } from 'app/screens/form-screen' import { makeStyles } from 'app/styles' +import type { FormValues } from '../types' + const messages = { title: 'ISRC/ISWC', isrc: 'ISRC', @@ -20,18 +23,31 @@ const useStyles = makeStyles(({ spacing }) => ({ export const IsrcIswcScreen = () => { const styles = useStyles() + + const { errors } = useFormikContext() + + const hasErrors = Boolean(errors.isrc || errors.iswc) + return ( - +