“Validation fiable dans Laravel” Réponses codées

Validation de Laravel

use Illuminate\Support\Facades\Validator;


$customMessage = [
  'title.max' => "title is too large",
];
$rules = [
  'id' => 'integer|exists:master_advert_bundles',
  'title' => ['required', 'unique:posts', 'max:255'],
  'body' => ['required']
];
$validate = validation($request->all(), $rules);
$validate = Validator::make($request->all(), $rules, $customMessage);
if ($validate->fails()) {
  return  $validate->messages();
}
Bored Bird

Validation de Laravel

    $validated = $request->validate([
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
    ]);
YellowSnowman85

Validation fiable dans Laravel

 'nriq'          => 'required',
            'nrim'          => 'required_if:nriq,Yes',
//multiple
  'cate'          => 'required',
   'ncl_cert' => 'required_if:cate,DT-VJ(A),NT(B),NT(D),OBC,SBC',
ashish basuri

Validation fiable dans Laravel

              $('#formid').validate({
                  rules: {
                      inservice_quota: "required",
                      inservice_jion_date: {
                          required: function () {
                              if ($('#idofpreviousfield').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      },
                      inservice_posting_addr: {
                          required: function () {
                              if ($('#InserviceQuota').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      },
                      inservice_establish_noc:{
                          required: function () {
                              if ($('#InserviceQuota').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      },
                      inservice_establish_noc_date:{
                          required: function () {
                              if ($('#Noc').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      },
                      inservice_dept_enquiry:{
                          required: function () {
                              if ($('#InserviceQuota').val() === 'Yes') {
                                  return true;
                              } else {
                                  return false;
                              }
                          },
                      }
                  },
                  messages: {
                      inservice_quota:{
                        required :"Please Select Inservice Quota"
                      },
                      inservice_jion_date:{
                          required :"Please select Date of Joining Permanent Service"
                      },
      
                  },
                  submitHandler: function (form) {

                      var action = "{{ route('Quota.store') }}";

                      $.ajax({
                          url: action,
                          data: $(form).serialize(),
                          type: 'post',
                          success: function (result) {
                              console.log(result.status);
                              if (result.status == "success") {
                                  toastr.success(result.msg);
                              }
                          },
                          error: function (response) {
                              let data = response.responseJSON.errors;
                              if (data) {
                                  $.each(data, function (index, jsonObject) {
                                      $.each(jsonObject, function (key, val) {
                                          console.log(val);
                                          toastr.error(val);
                                      });
                                      return false;
                                  });
                              }
                          }
                      });
                  }
              });
ashish basuri

Réponses similaires à “Validation fiable dans Laravel”

Questions similaires à “Validation fiable dans Laravel”

Plus de réponses similaires à “Validation fiable dans Laravel” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code