create_user_command.go 591 B

12345678910111213141516171819202122232425262728
  1. package command
  2. import "errors"
  3. type CreateUserCommand struct {
  4. // FirstName string
  5. // LastName string
  6. FirstName string `json:"first_name"`
  7. LastName string `json:"last_name"`
  8. }
  9. func NewCreateUserCommand(firstName, lastName string) *CreateUserCommand {
  10. return &CreateUserCommand{
  11. FirstName: firstName,
  12. LastName: lastName,
  13. }
  14. }
  15. // Validate valida los campos del comando
  16. func (c *CreateUserCommand) Validate() error {
  17. if c.FirstName == "" {
  18. return errors.New("el nombre es requerido")
  19. }
  20. if c.LastName == "" {
  21. return errors.New("el apellido es requerido")
  22. }
  23. return nil
  24. }