Add validation to blocks

This commit is contained in:
Julian Prieber 2024-10-15 12:39:10 +02:00
parent 434e6bbd7a
commit ac6daad444
7 changed files with 62 additions and 9 deletions

View File

@ -8,6 +8,15 @@
* @return array The prepared link data. * @return array The prepared link data.
*/ */
function handleLinkType($request, $linkType) { function handleLinkType($request, $linkType) {
$rules = [
'link' => [
'required',
'string',
'max:255',
],
];
// Prepare the link data // Prepare the link data
$linkData = [ $linkData = [
'title' => $request->title, 'title' => $request->title,
@ -15,5 +24,5 @@ function handleLinkType($request, $linkType) {
'link' => $request->link, 'link' => $request->link,
]; ];
return $linkData; return ['rules' => $rules, 'linkData' => $linkData];
} }

View File

@ -8,13 +8,20 @@
* @return array The prepared link data. * @return array The prepared link data.
*/ */
function handleLinkType($request, $linkType) { function handleLinkType($request, $linkType) {
$rules = [
'title' => [
'required',
'string',
'max:255',
],
];
// Prepare the link data // Prepare the link data
$linkData = [ $linkData = [
'title' => $request->title, 'title' => $request->title,
'button_id' => "42", 'button_id' => "42",
'var1' => "1",
'var2' => "1",
]; ];
return $linkData; return ['rules' => $rules, 'linkData' => $linkData];
} }

View File

@ -9,6 +9,14 @@
*/ */
function handleLinkType($request, $linkType) { function handleLinkType($request, $linkType) {
$rules = [
'title' => [
'required',
'string',
'max:255',
],
];
if ($request->GetSiteIcon == "1") { if ($request->GetSiteIcon == "1") {
$buttonID = "2"; $buttonID = "2";
} else { } else {
@ -21,5 +29,5 @@ function handleLinkType($request, $linkType) {
'button_id' => $buttonID, 'button_id' => $buttonID,
]; ];
return $linkData; return ['rules' => $rules, 'linkData' => $linkData];
} }

View File

@ -8,11 +8,19 @@
* @return array The prepared link data. * @return array The prepared link data.
*/ */
function handleLinkType($request, $linkType) { function handleLinkType($request, $linkType) {
$rules = [
'height' => [
'required',
'max:255',
],
];
// Prepare the link data // Prepare the link data
$linkData = [ $linkData = [
'title' => $request->height ?? null, 'title' => $request->height ?? null,
'button_id' => "43", 'button_id' => "43",
]; ];
return $linkData; return ['rules' => $rules, 'linkData' => $linkData];
} }

View File

@ -8,11 +8,20 @@
* @return array The prepared link data. * @return array The prepared link data.
*/ */
function handleLinkType($request, $linkType) { function handleLinkType($request, $linkType) {
$rules = [
'link' => [
'required',
'max:255',
],
];
// Prepare the link data // Prepare the link data
$linkData = [ $linkData = [
'title' => $request->title, 'title' => $request->title,
'button_id' => "44", 'button_id' => "44",
'link' => $request->link,
]; ];
return $linkData; return ['rules' => $rules, 'linkData' => $linkData];
} }

View File

@ -8,6 +8,15 @@
* @return array The prepared link data. * @return array The prepared link data.
*/ */
function handleLinkType($request, $linkType) { function handleLinkType($request, $linkType) {
$rules = [
'text' => [
'required',
'string',
'max:5000',
],
];
// Sanitize the text input // Sanitize the text input
$sanitizedText = $request->text; $sanitizedText = $request->text;
$sanitizedText = strip_tags($sanitizedText, '<a><p><strong><i><ul><ol><li><blockquote><h2><h3><h4>'); $sanitizedText = strip_tags($sanitizedText, '<a><p><strong><i><ul><ol><li><blockquote><h2><h3><h4>');
@ -24,5 +33,5 @@ function handleLinkType($request, $linkType) {
'button_id' => "93", // Assuming '93' is a predefined ID for a "text" button 'button_id' => "93", // Assuming '93' is a predefined ID for a "text" button
]; ];
return $linkData; return ['rules' => $rules, 'linkData' => $linkData];
} }

View File

@ -8,6 +8,9 @@
* @return array The prepared link data. * @return array The prepared link data.
*/ */
function handleLinkType($request, $linkType) { function handleLinkType($request, $linkType) {
$rules = [];
// Extract the necessary data from the request // Extract the necessary data from the request
$data = $request->only([ $data = $request->only([
'prefix', 'first_name', 'middle_name', 'last_name', 'suffix', 'nickname', 'prefix', 'first_name', 'middle_name', 'last_name', 'suffix', 'nickname',
@ -25,5 +28,5 @@ function handleLinkType($request, $linkType) {
'button_id' => "96", 'button_id' => "96",
]; ];
return $linkData; return ['rules' => $rules, 'linkData' => $linkData];
} }