localize new tagInput component errors

This commit is contained in:
feruz 2020-01-09 05:54:14 +02:00
parent 2e09e82ac0
commit 22732bb94b
2 changed files with 29 additions and 9 deletions

View File

@ -41,30 +41,42 @@ const TagInput = ({
cats.length > 10
? Alert.alert(
intl.formatMessage({ id: 'alert.error' }),
'Only 10 tags allowed, remove some',
intl.formatMessage({ id: 'editor.limited_tags' }),
)
: cats.find(c => c.length > 24)
? Alert.alert(
intl.formatMessage({ id: 'alert.error' }),
'Tag maximum length should be 24',
intl.formatMessage({ id: 'editor.limited_length' }),
)
: cats.find(c => c.split('-').length > 2)
? Alert.alert(intl.formatMessage({ id: 'alert.error' }), 'Use one dash in Tags')
? Alert.alert(
intl.formatMessage({ id: 'alert.error' }),
intl.formatMessage({ id: 'editor.limited_dash' }),
)
: cats.find(c => c.indexOf(',') >= 0)
? Alert.alert(intl.formatMessage({ id: 'alert.error' }), 'Use space to separate Tags')
? Alert.alert(
intl.formatMessage({ id: 'alert.error' }),
intl.formatMessage({ id: 'editor.limited_space' }),
)
: cats.find(c => /[A-Z]/.test(c))
? Alert.alert(intl.formatMessage({ id: 'alert.error' }), 'Only use lower letters in Tags')
? Alert.alert(
intl.formatMessage({ id: 'alert.error' }),
intl.formatMessage({ id: 'editor.limited_lowercase' }),
)
: cats.find(c => !/^[a-z0-9-#]+$/.test(c))
? Alert.alert(
intl.formatMessage({ id: 'alert.error' }),
'Use only allowed characters in Tags',
intl.formatMessage({ id: 'editor.limited_characters' }),
)
: cats.find(c => !/^[a-z-#]/.test(c))
? Alert.alert(intl.formatMessage({ id: 'alert.error' }), 'Tag must start with letter')
? Alert.alert(
intl.formatMessage({ id: 'alert.error' }),
intl.formatMessage({ id: 'editor.limited_firstchar' }),
)
: cats.find(c => !/[a-z0-9]$/.test(c))
? Alert.alert(
intl.formatMessage({ id: 'alert.error' }),
'Tag must end with letter or number',
intl.formatMessage({ id: 'editor.limited_lastchar' }),
)
: null;
handleTagChanged([...cats]);

View File

@ -252,7 +252,15 @@
"publish": "Publish",
"reply": "Reply",
"open_gallery": "Open Gallery",
"capture_photo": "Capture a photo"
"capture_photo": "Capture a photo",
"limited_tags": "Only 10 tags allowed, remove some",
"limited_length": "Maximum length of each tag should be 24",
"limited_dash": "Use one dash in each tag",
"limited_space": "Use space to separate tags",
"limited_lowercase": "Only use lower letters in tag",
"limited_characters": "Use only allowed characters in tag",
"limited_firstchar": "Tag must start with a letter",
"limited_lastchar": "Tag must end with letter or number"
},
"pincode": {
"enter_text": "Enter PIN to unlock",