Repository URL to install this package:
|
Version:
4.1.0-ulta.3 ▾
|
import {
formatPhoneNumber,
removePhoneNumberFormatting,
} from '@skava/utils'
import isValidTelephone from 'src/forms/deps/isValidTelephone'
import isValidEmail from 'src/forms/deps/isValidEmail'
import isValidPassword from 'src/forms/deps/isValidPassword'
import { TextBoxProps, TextBoxState, TextBoxComponent } from '../typings'
export function blurMiddleware(
event: Event,
props: TextBoxProps,
state: TextBoxState
) {
const { validationType, doesMatchesUserName } = props
// onFocus: handleFocus,
// onValidation: handleValidation,
if (
validationType !== 'newPassword' &&
validationType !== 'confirmPassword' &&
validationType !== 'expirationMonth' &&
validationType !== 'expirationYear' &&
validationType !== 'month' &&
validationType !== 'year'
) {
state.validateInput()
if (validationType === 'telephone') {
// this.state.value = formatPhoneNumber(this.state.value)
const value = isValidTelephone(state.value)
// this.state.setValue(value)
} else if (validationType === 'email') {
const value = isValidEmail(state.value)
// this.state.setValue(value)
} else if (validationType === 'password') {
// console.log('Inside textbox', this)
const matchValue = doesMatchesUserName
? doesMatchesUserName(state)
: false
const value = !matchValue && isValidPassword(state.value)
// this.state.setValue(value);
}
}
}