---
# System prepended metadata

title: 'Finishing sending flow, unhandled links - Mon, Tues 10th-11th Nov, 2020'
tags: [C+, validation, webview, unhandledlinks, setFieldTouched, programmingjournal, '2020']

---

# Finishing sending flow, unhandled links - Mon, Tues 10th-11th Nov, 2020

Spent most of these last two days finishing off the send recognition flow.

The main pain point was around validation:

```typescript=
if (data?.recognitionRecipients.results.ineligible.length === 0) {
    setFieldValue('recipientsEligible', 'eligible')
    // only touch field when eligible, incorrect validation if you touch when ineligible
    setTimeout(() => setFieldTouched('recipientsEligible', true))
}

if (data && data.recognitionRecipients.results.ineligible.length > 0) {
    setFieldValue('recipientsEligible', 'ineligible')
  }
```
Formik and Yup validation brings a lot, but also created headaches here!


### Open all unhandled links in default browser
```typescript=
onShouldStartLoadWithRequest={(request) => {
    const { url } = request
    const pattern = /^((http|https):\/\/)/

    try {
        if (pattern.test(url) && url.includes('/profile')) {
            const regexMatch = url.match('/profile/(.*)$')
            if (regexMatch) {
                navigateToUserProfile()
                return false
            }
        } else if (pattern.test(url)) {
            Linking.canOpenURL(url).then((canOpen) => {
                if (canOpen) {
                    Linking.openURL(url)
                }
            })

            return false
        }
    } catch (error) {
        // eslint-disable-next-line no-console
        console.error('Cannot open this url: ', error)
        return false
    }
    return true
}}
```

###### tags: `programmingjournal` `2020` `C+` `validation` `setFieldTouched` `webview` `unhandledlinks`