W
W
WhatYouDoing2019-06-22 16:02:06
Laravel
WhatYouDoing, 2019-06-22 16:02:06

Why is the validator not validating?

function onUserRegister(){
    $lang = [
        'required' => 'Все поля обязательны к заполнению!',
        'first_name.required' => 'Введите ваше имя!',
    ];
    $data = post();

    $rules = [
        'first_name.required'=>'Поле обязательно к заполнению'
    ];

    $validation = Validator::make($data, $rules, $lang);

    if ($validation->fails()) {
        throw new ValidationException($validation);
    }
}

<form id="register" class="text-center" data-request="onUserRegister" data-request-validate>
                                <p class="status"></p>
                                <label class="grey-text" class="grey-text" for="first_name">Имя</label>
                                <input type="text" id="first_name" class="form-control" name="first_name">
                                <br>

                                <label class="grey-text" for="first_name">Фамилия</label>
                                <input type="text" id="surname" class="form-control" name="surname">
                                <br>

                                <label class="grey-text" for="email">E-mail</label>
                                <input type="text" id="email" class="form-control" name="email">
                                <br>

                                <label class="grey-text" for="password">Пароль</label>
                                <input type="password" id="password" class="form-control" name="password">
                                <div class="mt-4">
                                    <button class="btn btn-info btn-md mb-4 waves-effect waves-light" type="submit">Продолжить</button>
                                </div>
                                <div class="alert alert-danger" data-validate-error>
                                    <p data-message></p>
                                </div>

I use OCTOBER CMS, styles and framework extras are included in the template, no errors are returned when validating, even if I send an empty field, what could be the matter?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question