wix / react-native-ui-lib

UI Components Library for React Native

Home Page:https://wix.github.io/react-native-ui-lib/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Textfield built in validators should allow empty strings

brianangulo opened this issue · comments

Description

When using the built in validators for the TextField component such as validate={['email']}, validate={['number']} it throws as invalid when the fields are cleared to empty string. This happens despite the fields being not required

Related to

  • Components
  • Demo
  • Docs
  • Typings

Steps to reproduce

Use built in validators on a TextField component

Expected behavior

I would expect for validation to be positive if the field is not labeled with the validation 'required' and is cleared/deleted

Actual behavior

For fields not marked with 'required' validators but with other built in ones it still shows an error if the field is cleared

More Info

Code snippet

<TextField
            placeholder="email@email.com..."
            label="Email"
            onChangeText={(val: string) => handleFieldChange('email', val)}
            value={employeeData.email || ''}
            labelStyle={{
              fontSize,
              lineHeight: fontSize,
              color: theme.colors.text,
              marginBottom: '2%',
            }}
            validate={['email']}
            validationMessage={['Must be a valid email']}
            validationMessageStyle={{ color: theme.colors.error }}
            style={{ fontSize, lineHeight: fontSize, color: theme.colors.text }}
            placeholderTextColor={theme.colors.info}
            validateOnChange
            enableErrors
            onChangeValidity={(isValid) =>
              handleOnValidationChange(isValid, 'email')
            }
          />

Screenshots/Video

Screenshot 2023-11-14 at 1 12 05 PM

Environment

expo-env-info 1.0.5 environment info:
System:
OS: macOS 13.6
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.18.0/bin/yarn
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
Watchman: 2023.09.25.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.13.0 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
IDEs:
Android Studio: 2022.3 AI-223.8836.35.2231.10811636
Xcode: 15.0/15A240d - /usr/bin/xcodebuild
npmPackages:
expo: ~49.0.15 => 49.0.16
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.72.6 => 0.72.6
react-native-web: ~0.19.6 => 0.19.9
npmGlobalPackages:
eas-cli: 5.4.0
expo-cli: 6.3.10
Expo Workflow: managed

Affected platforms

  • Android
  • iOS
  • Web