Laravel form request check if two passwords match? - laravel-5

I am working on a user registration form in laravel 5. I wish to know is it possible to use laravel's form request validation to check if the two passwords submitted by the user are thesame. Is it possible to do that with using requests?

Yes, it's possible.
There is an validator called confirmed.
confirmed
The field under validation must have a matching field of
foo_confirmation. For example, if the field under validation is
password, a matching password_confirmation field must be present in
the input.
https://laravel.com/docs/5.2/validation#rule-confirmed

Related

unique entity validation for add and edit forms

I use unique entity validation in username property of user entity,
when the user is going to be added that is ok,
but when the user is going to be edited, and username is not changed the unique entity validation impede this, because the same object already exist with that username,
how can I handle this?
PD:sorry for my poor english
Use validations groups. Link your UniqueEntity constraint to a validation group "new", then only link this group to your form when you are creating a User.

How can redux-form validation based on multiple fields be implemented?

Redux Form validation examples only include individual field validations.
Having a list of a certain number of fields that are the same, how can I model a validation that requires at least one of the inputs to be a valid email address?
For example, for the given form made up of the following fields:
User 1,
User 2,
User 3,
Special User 4
How can I write a validation function that requires Special User 4 to always be set, and either one of the first 3 users?
Your synchronous validation function is given all the values of the form. Your errors must correspond to a field key, or you can use the generic _error key, which will result in this.props.error being populated.
Does that make sense?

Unique field validation in Google forms

Using Google forms, data can saved to the spreadsheet. Now i would like to apply validation in Username field for avoid duplication. How can add UNIQUE validation in google form field using Google script?
I think it is not possible to add validation for fields in Google form values by using Google Apps Script direcly.
One thing you can consider to change the settings in the Google form itself, if the Username field value is same as the Username that logged in to access that form. You can do this by checking the "only allow one response per person(required login)".
If the above solution does not apply for your requirement, the UiApp/Html Service in Apps Script will help you in creating custom forms.
You can create a custom form and write a custom function to get the Username field values using SpreadsheetApp class into an array. Before submitting the Form, compare the Username field from Google form with the list of username cell values that we got in an array and check for uniqueness.
Hope that helps!

Cakephp one model different form validation

I have a model name "User", their I added a validation for login. But I need to validate registration page also. Fields for both forms are different.
Can someone please tell me how to manage different form validation with 1 model.
You can validate as many fields as you want inside your User model, it does not matter in which View or in which form you input them.
So just add the fields from your registration page to the User's $validate inside your User model.
If all forms share similar fieldnames but require different validation rules you can use:
http://bakery.cakephp.org/articles/dardosordi/2008/07/29/multivalidatablebehavior-using-many-validation-rulesets-per-model
If the duplicate fields validate the same on all forms you can just add them all to the Model, it will only validate the ones present on the form.
Remember to NOT use 'required' => true, setting this key to true will make the field always required and it has to be present in the data array even if it's not on your form

Custom Data Annotation Attribute using Metadata

My requirement is to create a custom data annotation attribute for my project. The requirement is to validate the min/ max length of a specific product from the database, which will be retrieved from the database using the ProductID. I have a dynamic page for each product where there are two fields called max length & min length. User inputs the values in these two fields which needs to be validated from the database. Product table contains all the products & one will be selected by passing a productId.
Please suggest some pointers to implement the above.
Thanks in advance.
This validation you can do only in the server side and not in client, so I see two options.
Remote Validation - You can use remote validation when you want to perform the validation and show the error message through ajax.
IValidatableObject - By implementing this interface in the class you can do both the validations at the same time and return all the validation error messages as a collection. By this way the validation will happen after the form is normally submitted.

Resources