diff --git a/types/react-tag-autocomplete/index.d.ts b/types/react-tag-autocomplete/index.d.ts index 15273e3918..80a088f8a8 100644 --- a/types/react-tag-autocomplete/index.d.ts +++ b/types/react-tag-autocomplete/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for react-tag-autocomplete 5.6 // Project: https://github.com/i-like-robots/react-tags#readme // Definitions by: James Lismore +// Rahul Sagore // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -81,6 +82,10 @@ export interface ReactTagsProps { * Optional event handler when the input changes. Receives the current input value. */ handleInputChange?: (input: string) => void; + /** + * Optional validation function that determines if tag should be added to tags. Receives a tag object. Should return a boolean. + */ + handleValidate?: (tag: Tag) => boolean; /** * An object containing additional attributes that will be applied to the underlying field. */ diff --git a/types/react-tag-autocomplete/react-tag-autocomplete-tests.tsx b/types/react-tag-autocomplete/react-tag-autocomplete-tests.tsx index 0777d682da..d42f07ff8f 100644 --- a/types/react-tag-autocomplete/react-tag-autocomplete-tests.tsx +++ b/types/react-tag-autocomplete/react-tag-autocomplete-tests.tsx @@ -30,6 +30,7 @@ class TestAll extends React.Component { const onBlur = () => {}; const onFocus = () => {}; const onInputChange = (input: string) => {}; + const onValidate = (tag: { id: string | number; name: string }) => true; const inputAttributes = { maxLength: 10 }; const suggestions = [ { id: 3, name: "Bananas" }, @@ -55,6 +56,7 @@ class TestAll extends React.Component { handleDelete={onDeleteTag} handleFocus={onFocus} handleInputChange={onInputChange} + handleValidate={onValidate} inputAttributes={inputAttributes} maxSuggestionsLength={10} minQueryLength={5}