Welcome Guest, Not a member yet? Register   Sign In
Form Validation Allowing Empty Strings To Be Stored Instead of Null
#3

Sorry, I think I deleted them accidentally when editing my post. Here's the rules and messages again. Still having the problem.

If the JSON doesn't contain name and email, I want it to throw a required error.

PHP Code:
protected $validationRules = [
        'id' => 'required|numeric|is_unique[users.id]',
        'name' => 'required',
        'email' => 'required|valid_email|is_unique[users.email]'
    ];
    protected $validationMessages = [
        'id' => [
            'required' => 'An ID is required. This is normally a Podio Item ID.',
            'numeric' => 'ID must be numeric.',
            'is_unique' => 'A record with this ID already exists.'
        ],
        'name' => [
            'required' => 'A name is required.'
        ],
        'email' => [
            'required' => 'An email address is required.',
            'valid_email' => 'You must enter a valid email address.',
            'is_unique' => 'The email address already exists in the system.'
        ]
    ]; 
Reply


Messages In This Thread
RE: Form Validation Allowing Empty Strings To Be Stored Instead of Null - by viewfromthenorth - 10-07-2019, 08:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB