handleIsValid removal, Form validity check for tags and title length

This commit is contained in:
feruz 2020-01-10 07:04:24 +02:00
parent f6b490ecf1
commit a1e0223b20
2 changed files with 5 additions and 11 deletions

View File

@ -12,7 +12,6 @@ import globalStyles from '../../../../globalStyles';
const TagInput = ({ const TagInput = ({
value, value,
onChange, onChange,
handleIsValid,
componentID, componentID,
handleTagChanged, handleTagChanged,
intl, intl,
@ -57,14 +56,11 @@ const TagInput = ({
handleTagChanged([...cats]); handleTagChanged([...cats]);
} }
if (handleIsValid) {
handleIsValid(componentID, !!(_text && _text.length));
}
}; };
const _handleOnBlur = () => { const _handleOnBlur = () => {
let cats = [];
if (onChange) { if (onChange) {
let cats = text.trim().split(' '); cats = text.trim().split(' ');
if (handleTagChanged && cats.length > 0) { if (handleTagChanged && cats.length > 0) {
cats.length > 10 cats.length > 10
? (setWarning(intl.formatMessage({ id: 'editor.limited_tags' })), setHeight(60)) ? (setWarning(intl.formatMessage({ id: 'editor.limited_tags' })), setHeight(60))
@ -87,10 +83,6 @@ const TagInput = ({
} }
onChange(text); onChange(text);
} }
if (handleIsValid) {
handleIsValid(componentID, !!(text && text.length));
}
}; };
return ( return (
<View style={[globalStyles.containerHorizontal16, { height: Math.max(35, height) }]}> <View style={[globalStyles.containerHorizontal16, { height: Math.max(35, height) }]}>

View File

@ -131,8 +131,10 @@ class EditorScreen extends Component {
} else { } else {
isFormValid = isFormValid =
get(fields, 'title', '') && get(fields, 'title', '') &&
get(fields, 'title', '').length < 255 &&
(get(fields, 'body', '') || (bodyText && bodyText > 0)) && (get(fields, 'body', '') || (bodyText && bodyText > 0)) &&
get(fields, 'tags', null); get(fields, 'tags', null) &&
get(fields, 'tags', null).length < 10;
} }
this.setState({ isFormValid }); this.setState({ isFormValid });