2

I have just started learning cfwheels. I was working on the sample "Social Networking Site" example present in the site(http://cfwheels.org/screencasts/series/1). I have a doubt. We have register.cfm and login.cfm two views present. Both the veiws are using the user object created from Person.cfc(modal).

All the validations that are required in the registration form , we have written inside Person.cfc init() method. Now on the login.cfm we have two fields named Email and password and I want to validate the email to be in correct format in server side before checking for valid Email/Password combination.

Now where should I write this validation code for login.cfm?

Deepak Kumar Padhy
  • 4,128
  • 6
  • 43
  • 79

1 Answers1

3

The server side validation should be done on the action inside the Controller. For example if you are submitting the form to doLogin action of the Authentication controller/component, the validation code should go inside the doLogin() function of the same controller.

Pankaj
  • 1,731
  • 1
  • 13
  • 15
  • But in the Example for registration form validation, the validation code was inside the Person.cfc modal not inside the `Main` controllers `register` action. thats why I am confused validation should be inside model or controller? – Deepak Kumar Padhy Feb 13 '15 at 09:23
  • Anything written in Model cfc is meant for database. If you want CFWheels to validate data while performing database operations then the validation code should go in Model cfc. But if you want server side validation then it's always the Controller where you write the validation. – Pankaj Feb 13 '15 at 09:40