Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onSubmit: ({ searchInput }, dispatch) => {
if (isMixed(searchInput) || isEmpty(searchInput)) {
// TODO: notify? shake? color searchbar?
console.warn('Invalid search input');
return false;
}
const payload = {
meaningContains: isRomaji(searchInput) ? searchInput : '',
readingContains: isJapanese(searchInput) ? searchInput : '',
};
return dispatch(app.review.search.request(payload));
},
})(SearchBar);
onSubmit: ({ keywords }, dispatch, form) => {
if (isMixed(keywords)) {
form.stopSubmit({ keywords: 'Mixed input' });
} else {
const query = {};
if (isRomaji(keywords)) {
query.meaningContains = keywords.toLowerCase();
} else if (isJapanese(keywords)) {
query.readingContains = keywords;
}
dispatch(search.query.request(query, { form }));
}
},
})(SearchBar);
const isInputValid = (input = '') => !isEmpty(input) && isJapanese(input);
const cleanseInput = (input = '') => fixTerminalN(input.trim());
export const isInputValid = (input = '') =>
!containsZenkakuLatin(input) && isJapanese(input, /[0-9]/);
export const cleanseInput = (input = '') => fixTerminalN(input.trim());
export const onlyKanjiKana = (value = '') =>
isJapanese(value) ? undefined : 'Must be a mix of kanji and okurigana';
const isInputValid = (input = '') => !isEmpty(input) && isJapanese(input);
const cleanseInput = (input = '') => fixTerminalN(input.trim());
export const onlyKanjiKana = (value = '') => isJapanese(value) ? undefined : 'Must be a mix of kanji and okurigana';