Fixed extra question validation input
unified validation criteria for extra questions Change-Id: Ib312fb294705fba38f710ebe032828d7d45b236e Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
048a7e845a
commit
df9cbe6d4c
|
@ -327,7 +327,7 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
|||
'will_all_speakers_attend' => 'sometimes|boolean',
|
||||
'links' => 'sometimes|url_array',
|
||||
'tags' => 'sometimes|string_array',
|
||||
'extra_questions' => 'sometimes|entity_value_array',
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array',
|
||||
];
|
||||
|
||||
$data = $data->all();
|
||||
|
@ -398,7 +398,7 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
|||
'attending_media' => 'required|boolean',
|
||||
'links' => 'sometimes|url_array',
|
||||
'tags' => 'sometimes|string_array',
|
||||
'extra_questions' => 'sometimes|entity_value_array',
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array',
|
||||
];
|
||||
|
||||
$data = $data->all();
|
||||
|
|
|
@ -519,7 +519,7 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
|
|||
'company' => 'nullable|sometimes|string|max:255',
|
||||
'email' => 'required_without:member_id|string|max:255|email',
|
||||
'member_id' => 'required_without:email|integer',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array',
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array',
|
||||
];
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
|
@ -607,7 +607,7 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
|
|||
'company' => 'nullable|sometimes|string|max:255',
|
||||
'email' => 'required_without:member_id|string|max:255|email',
|
||||
'member_id' => 'required_without:email|integer',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array',
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array',
|
||||
'admin_notes' => 'nullable|sometimes|string|max:1024',
|
||||
];
|
||||
|
||||
|
@ -793,7 +793,7 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
|
|||
'attendee_last_name' => 'nullable|string|max:255',
|
||||
'attendee_email' => 'required|string|max:255|email',
|
||||
'attendee_company' => 'nullable|string|max:255',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array'
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array'
|
||||
]);
|
||||
|
||||
$ticket = $this->attendee_service->reassignAttendeeTicket($summit, $attendee, intval($ticket_id), $payload);
|
||||
|
|
|
@ -103,7 +103,7 @@ final class OAuth2SummitOrdersApiController
|
|||
|
||||
$validation_rules = [
|
||||
'tickets' => 'required|ticket_dto_array',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array',
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array',
|
||||
'owner_company' => 'nullable|string|max:255',
|
||||
];
|
||||
|
||||
|
@ -435,7 +435,7 @@ final class OAuth2SummitOrdersApiController
|
|||
try {
|
||||
$current_user = $this->getResourceServerContext()->getCurrentUser();
|
||||
$payload = $this->getJsonPayload([
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array',
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array',
|
||||
'owner_company' => 'sometimes|string|max:255',
|
||||
'billing_address_1' => 'sometimes|string|max:255',
|
||||
'billing_address_2' => 'sometimes|string|max:255',
|
||||
|
@ -594,7 +594,7 @@ final class OAuth2SummitOrdersApiController
|
|||
'attendee_last_name' => 'nullable|string|max:255',
|
||||
'attendee_email' => 'required|string|max:255|email',
|
||||
'attendee_company' => 'nullable|string|max:255',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array'
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array'
|
||||
]);
|
||||
|
||||
$ticket = $this->service->ownerAssignTicket($current_user, intval($order_id), intval($ticket_id), $payload);
|
||||
|
@ -711,7 +711,7 @@ final class OAuth2SummitOrdersApiController
|
|||
'attendee_last_name' => 'nullable|string|max:255',
|
||||
'attendee_email' => 'required|string|max:255|email',
|
||||
'attendee_company' => 'nullable|string|max:255',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array'
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array'
|
||||
]);
|
||||
|
||||
$ticket = $this->service->updateTicket($summit, intval($order_id), intval($ticket_id), $payload);
|
||||
|
@ -756,7 +756,7 @@ final class OAuth2SummitOrdersApiController
|
|||
'attendee_last_name' => 'nullable|string|max:255',
|
||||
'attendee_email' => 'required|string|max:255|email',
|
||||
'attendee_company' => 'nullable|string|max:255',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array'
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array'
|
||||
]);
|
||||
|
||||
$ticket = $this->service->addTicket($summit, intval($order_id), $payload);
|
||||
|
@ -932,7 +932,7 @@ final class OAuth2SummitOrdersApiController
|
|||
'attendee_company' => 'nullable|string|max:255',
|
||||
'disclaimer_accepted' => 'nullable|boolean',
|
||||
'share_contact_info' => 'nullable|boolean',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array'
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array'
|
||||
]);
|
||||
|
||||
$ticket = $this->service->updateTicketByHash($hash, $payload);
|
||||
|
@ -1006,7 +1006,7 @@ final class OAuth2SummitOrdersApiController
|
|||
'attendee_company' => 'nullable|string|max:255',
|
||||
'disclaimer_accepted' => 'nullable|boolean',
|
||||
'share_contact_info' => 'nullable|boolean',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array'
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array'
|
||||
]);
|
||||
|
||||
$ticket = $this->service->updateTicketById($current_user, $ticket_id, $payload);
|
||||
|
@ -1095,7 +1095,7 @@ final class OAuth2SummitOrdersApiController
|
|||
'owner_id' => 'required_without:owner_first_name,owner_last_name,owner_email|int',
|
||||
'ticket_type_id' => 'required|int',
|
||||
'promo_code' => 'sometimes|string',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array',
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array',
|
||||
'owner_company' => 'required|string|max:255',
|
||||
'billing_address_1' => 'sometimes|string|max:255',
|
||||
'billing_address_2' => 'sometimes|string|max:255',
|
||||
|
@ -1139,7 +1139,7 @@ final class OAuth2SummitOrdersApiController
|
|||
'owner_last_name' => 'required_without:owner_id|string|max:255',
|
||||
'owner_email' => 'required_without:owner_id|string|max:255|email',
|
||||
'owner_id' => 'required_without:owner_first_name,owner_last_name,owner_email|int',
|
||||
'extra_questions' => 'sometimes|order_extra_question_dto_array',
|
||||
'extra_questions' => 'sometimes|extra_question_dto_array',
|
||||
'owner_company' => 'required|string|max:255',
|
||||
'billing_address_1' => 'sometimes|string|max:255',
|
||||
'billing_address_2' => 'sometimes|string|max:255',
|
||||
|
|
|
@ -57,12 +57,12 @@ class AppServiceProvider extends ServiceProvider
|
|||
'extra_questions' => 'sometimes|order_extra_question_dto_array'
|
||||
];
|
||||
|
||||
static $order_extra_question_dto_fields = [
|
||||
static $extra_question_dto_fields = [
|
||||
'question_id',
|
||||
'answer',
|
||||
];
|
||||
|
||||
static $order_extra_question_dto_validation_rules = [
|
||||
static $extra_question_dto_validation_rules = [
|
||||
'question_id' => 'required|int',
|
||||
'answer' => 'nullable|string|max:255',
|
||||
];
|
||||
|
@ -205,12 +205,12 @@ class AppServiceProvider extends ServiceProvider
|
|||
return true;
|
||||
});
|
||||
|
||||
Validator::extend('order_extra_question_dto_array', function($attribute, $value, $parameters, $validator)
|
||||
Validator::extend('extra_question_dto_array', function($attribute, $value, $parameters, $validator)
|
||||
{
|
||||
$validator->addReplacer('order_extra_question_dto_array', function($message, $attribute, $rule, $parameters) use ($validator) {
|
||||
$validator->addReplacer('extra_question_dto_array', function($message, $attribute, $rule, $parameters) use ($validator) {
|
||||
return sprintf
|
||||
(
|
||||
"%s should be an array of order extra question data {question_id : int, answer: string}",
|
||||
"%s should be an array of extra question data {question_id : int, answer: string}",
|
||||
$attribute);
|
||||
});
|
||||
|
||||
|
@ -219,11 +219,11 @@ class AppServiceProvider extends ServiceProvider
|
|||
foreach($value as $element)
|
||||
{
|
||||
foreach($element as $key => $element_val){
|
||||
if(!in_array($key, self::$order_extra_question_dto_fields)) return false;
|
||||
if(!in_array($key, self::$extra_question_dto_fields)) return false;
|
||||
}
|
||||
|
||||
// Creates a Validator instance and validates the data.
|
||||
$validation = Validator::make($element, self::$order_extra_question_dto_validation_rules);
|
||||
$validation = Validator::make($element, self::$extra_question_dto_validation_rules);
|
||||
|
||||
if($validation->fails()) return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue