regex for url slug text added

Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
Benny Samir Hierl 2022-02-19 21:55:16 +01:00
parent 9f63089261
commit 43f389c29b
5 changed files with 24 additions and 19 deletions

View file

@ -84,9 +84,9 @@ const schema = object().shape(
300, 300,
t('components.form-wishlist.description.error-max') t('components.form-wishlist.description.error-max')
), ),
slugUrlText: string().required( slugUrlText: string()
t('components.form-wishlist.slug-text.error-requried') .required(t('components.form-wishlist.slug-text.error-requried'))
), .matches(/^[\w-]+$/, t('components.form-wishlist.slug-text.error-regex')),
imageSrc: string().when('imageFile', { imageSrc: string().when('imageFile', {
is: (imageFile: string) => !imageFile || imageFile.length === 0, is: (imageFile: string) => !imageFile || imageFile.length === 0,
then: string().required( then: string().required(

View file

@ -51,11 +51,12 @@ const props = defineProps({
default: false, default: false,
}, },
}) })
const { value: inputValue, errorMessage, handleBlur, handleChange } = useField( const {
props.name, value: inputValue,
undefined, errorMessage,
{ handleBlur,
initialValue: props.value, handleChange,
} } = useField(props.name, undefined, {
) initialValue: props.value,
})
</script> </script>

View file

@ -55,11 +55,12 @@ const props = defineProps({
default: false, default: false,
}, },
}) })
const { value: inputValue, errorMessage, handleBlur, handleChange } = useField( const {
props.name, value: inputValue,
undefined, errorMessage,
{ handleBlur,
initialValue: props.value, handleChange,
} } = useField(props.name, undefined, {
) initialValue: props.value,
})
</script> </script>

View file

@ -136,7 +136,8 @@
}, },
"slug-text": { "slug-text": {
"label": "URL Slug-Text", "label": "URL Slug-Text",
"error-requried": "URL Slug-Text wird benötigt." "error-requried": "URL Slug-Text wird benötigt.",
"error-regex": "Unngültige URL Slug-Text."
}, },
"image-src": { "image-src": {
"label": "Bild-URL", "label": "Bild-URL",

View file

@ -135,7 +135,9 @@
"error-max": "The max. length is 300 chars." "error-max": "The max. length is 300 chars."
}, },
"slug-text": { "slug-text": {
"label": "URL Slug-Text" "label": "URL Slug-Text",
"error-requried": "URL Slug-Text is required.",
"error-regex": "Invalid URL Slug-Text."
}, },
"image-src": { "image-src": {
"label": "Image-URL", "label": "Image-URL",