function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sreedharp286sreedharp286 

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 ?

sfdcfoxsfdcfox
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.