+ Start a Discussion

How to write Apex class and test class based on below conditions

How to write Apex class and test class  based on below conditions?

     A) Username should be unique.

     B) Username and password should not be same.

     C) Password should have alphanumeric characters.


  Can any one help me ?

Assuming you're trying to insert a normal User object, the first is automatically enforced, the second and third are controlled by Setup > Security Controls > Password Settings. If you're using a custom object that represents a user, the first can be automatically enforced with a unique index on a field, and the only part left is to verify that the password meets the complexity requirements.