Flash Errormessages to big?


#1

I have the following route validator

const antl = use(‘Antl’);

(‘use strict’);

class storeProduct {
get validateAll() {
console.log(‘in valdiate’);
return true;
}

get sanitizationRules() {
	return {
		margin_factor_cz_web_be: 'to_null',
		margin_factor_cz_web_nl: 'to_null',
		netto_profit_amount_cz_be: 'to_null',
		netto_profit_amount_cz_nl: 'to_null',
		margin_factor_dropshipping: 'to_null',
		margin_factor_wholesale: 'to_null',
		vat_procent: 'to_null',
		margin_factor_bol_be: 'to_null',
		margin_factor_bol_nl: 'to_null',
		shipping_cost_ex_vat_bol_be: 'to_null',
		shipping_cost_ex_vat_bol_nl: 'to_null',
		total_cost_ex_vat_bol_be: 'to_null',
		netto_profit_amount_bol_nl: 'to_null',
		netto_profit_amount_bol_be: 'to_null',
		total_cost_ex_vat_bol_nl: 'to_null',
		stock_start: 'to_null',
		stock_real: 'to_null',
		stock_accounting: 'to_null'
	};
}

get rules() {
	return {
		name_nl: 'required',
		slug_nl: 'required|unique:products:slug_nl',
		id_supplier: 'not_equals:0',
		id_bol_category: 'required',
		id_product_supplier: 'max:20',
		ean13: 'max:20'
	};
}

get messages() {
	const locale = this.ctx.antl._locale;
	const messages = antl.forLocale(locale).list('validators');
	return messages;
}

async fails(errorMessages) {
	const locale = this.ctx.antl._locale;
	console.log(errorMessages);
	this.ctx.session.withErrors(errorMessages).flashAll();

	return this.ctx.response.json(errorMessages);

	//return this.ctx.response.redirect('back');
}

}

module.exports = storeProduct;

PROBLEM IS : The errorMessages object is always ok but when i flash them they does not coming back if there are more then +/- 4 errors ?
Is there a max size on sessions or is there another problem ?


#2

Hey @RUDIWER! :wave:

You need to use the validateAll property.

https://adonisjs.com/docs/4.1/validator#_validate_all


#3

Hello,

I use validateAll (otherwise i get only one error but i get 4 or 5), thats not the problem errorMessages object is ok, all errors are in it, but when i flash them its like when there are more errors the file is to big and nothing comes back in view ? if i have more then 5 validation errors all errors are in the errorMessages object but when i do flashAll nothing comes back in the view ? whatever different errors i take so there is nothing wrong with validation rules or whatever, also tied to put the validation in the controller and the same result ??? this really breaks my head ? can this be a bug or is it me ???


#4

Worked by changing the driver. Discussed in discord


#5

With the help of virk it seems that cookie size was to small to handle all the errors changing session from cookie to file was the solution !
(can be a later problem when scaling up )

thanks !