public UserEntity(int id, String email, String name, string password) { if (id < 0) { throw new ArgumentException("Id must be >= 0."); } this.id = id; CredentialService credentialService = new CredentialService(); if (!credentialService.isNameValid(name)) { throw new ArgumentException("Name is invalid."); } this.name = name; if (!credentialService.isEmailValid(email)) { throw new ArgumentException("Email is invalid."); } this.email = email; if (!credentialService.isPasswordValid(password)) { throw new ArgumentException("Password is invalid."); } this.password = password; }