Repository URL to install this package:
Version:
0.9.5 ▾
|
import {
formatPhoneNumber,
removePhoneNumberFormatting,
} from '@skava/modules/___dist/utils/formatPhoneNumber'
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 !== 'confirmPassword' &&
validationType !== 'expirationmonth' &&
validationType !== 'expirationyear'
) {
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);
}
}
}