Strange Validation Behaviour |
Hi,
I have a simple validation rules configured in Config/Validation.php public $Quote_value = [ 'quote_value' => [ 'rules' => 'required|decimal', 'errors' => [ 'required'=> 'Quote Value is required', 'decimal' => 'Quote Value must be a valid number i.e. 100.00.' ] ], 'labour_estimate' => [ 'rules' => 'required|decimal', 'errors' => [ 'required'=> 'Labour Estimate is required', 'decimal' => 'Labour Estimate must be a valid number i.e. 100.00.' ] ], 'costs_estimate' => [ 'rules' => 'required|decimal', 'errors' => [ 'required'=> 'Costs Estimate is required', 'decimal' => 'Costs Estimate must be a valid number i.e. 100.00.' ] ], ]; My controller PHP Code: if ($this->request->getPost('quote_value')) { When quote_value = 100.00, labour_estimate=20.00, costs_estimate=10.00, and //Standalone Validation is used. NO ERRORS reported Using the same values and //Validate using Config/Validation.php. ERROR "The quote_value field must contain a decimal number." NOTE: I only use one validation method at a time when running the tests. This is strange on 4 levels 1) I did not expect an error returned 2) Why would the same rule work using one method and not the other 3) Why would one field fail validation and the other pass, when essentiallly they are identical 4) Why is CI4 not returning the text defined in 'errors' array of the validation rule (i.e. "Quote Value must be a valid number i.e. 100.00."). Note I get the same text using getErrors() and listErrors() I am viewing the validation reponse PHP Code: <?php if (session()->has('validation')) : ?> Very, very strange?? |
Welcome Guest, Not a member yet? Register Sign In |