Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Include onFeedback method to show the validation responses
Browse files Browse the repository at this point in the history
  • Loading branch information
guerrato committed Feb 16, 2022
1 parent bb439c3 commit b26f52d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib/components/inputs/basic/password/Password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const Password = (props: InputProps) => {

useEffect(() => {
props.onValidate?.call(null, getResultantValidationResponse(validationResponse))
props.onFeedback?.call(null, validationResponse)
}, [validationResponse])

return (
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/inputs/basic/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const Search = (props: InputProps) => {

useEffect(() => {
props.onValidate?.call(null, getResultantValidationResponse(validationResponse))
props.onFeedback?.call(null, validationResponse)
}, [validationResponse])

return (
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/inputs/basic/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type InputProps = {
criteria?: InputValidation | InputValidation[]
onChange?: ChangeEventHandler<HTMLInputElement>
onValidate?: (isValid: boolean) => void
onFeedback?: (validationResponse: InputCriteriaResponse | InputCriteriaResponse[]) => void
inputStyles?: SharedProps
readOnly?: boolean
autoComplete?: AutocompleteValues
Expand Down Expand Up @@ -80,7 +81,7 @@ export const criteriaRule = (
}

export const getResultantValidationResponse = (
validationResponse: InputCriteriaResponse | InputCriteriaResponse[] | undefined
validationResponse?: InputCriteriaResponse | InputCriteriaResponse[]
) => {
if (!validationResponse) {
return false
Expand Down
1 change: 1 addition & 0 deletions src/lib/components/inputs/basic/text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const Text = (props: InputProps) => {

useEffect(() => {
props.onValidate?.call(null, getResultantValidationResponse(validationResponse))
props.onFeedback?.call(null, validationResponse)
}, [validationResponse])

return (
Expand Down

0 comments on commit b26f52d

Please sign in to comment.