Giter VIP home page Giter VIP logo

Comments (3)

josecelano avatar josecelano commented on September 10, 2024

Hey @da2ce7, can you please review this? If we implement it as I have described it, we will remove the option to provide an email, even if it's not mandatory, until we allow it in the profile settings (new feature).

This could be a helpful feature for some reason. I think email is the only way to communicate with users now, so even if we don't require it, it could be useful to allow the user to provide it.

from torrust-index.

da2ce7 avatar da2ce7 commented on September 10, 2024

@josecelano

I would rename mail to email.

Here are the different variants.

Registration Disabled:

# [registration]

Registration without email option:

[registration]

Registration optionally including an email address:

[registration]
[registration.email]

Registration with email:

[registration]
[registration.email]
required = true

Registration with optional email, but if email is supplied it is verified:

[registration]
[registration.email]
verified = true

Registration with email and email is verified:

[registration]
[registration.email]
required = true
verified = true

from torrust-index.

josecelano avatar josecelano commented on September 10, 2024

Hi @da2ce7, just to confirm, do you prefer to represent the omitted value for required and verified with an Option or set the default value to false?

This would be the Rust struct using Options (omitting other configuration fields):

struct Config {
  registration: Option<Registration> // default None. Registration disabled.
}

struct Registration {
  mail: Option<Email> // default None. Registration without email.
}

struct Email {
  required: Option<bool>, // default None.
  verified: Option<bool>, // default None.
}

And this would be the Rust struct using defaults (omitting other configuration fields):

struct Config {
  registration: Option<Registration> // default None. Registration disabled.
}

struct Registration {
  mail: Option<Email> // default None. Registration without email.
}

struct Email {
  required: bool, // default false
  verified: bool, // default false
}

In practice, you must assume a true or false default value for Option. So I would use the direct option.

And these are the "debug" instances for each case (assuming no optional booleans):

Registration Disabled:

Config {
  registration: None
}

Registration without email option:

Config {
  registration: Some(Registration {
    mail: None
  })
}

Registration optionally including an email address:

Config {
  registration: Some(Registration {
    mail: Some({
      required: false,
      verified: false,
    })
  })
}

Registration with email:

Config {
  registration: Some(Registration {
    mail: Some({
      required: true,
      verified: false,
    })
  })
}

Registration with optional email, but if email is supplied it is verified:

Config {
  registration: Some(Registration {
    mail: Some({
      required: false,
      verified: true,
    })
  })
}

Registration with email and email is verified:

Config {
  registration: Some(Registration {
    mail: Some({
      required: true,
      verified: true,
    })
  })
}

And in JSON:

Registration Disabled:

{}

Registration without email option:

{
  "registration": {}
}

Registration optionally including an email address:

{
  "registration": {
    "email": {}
  }
}

Registration with email:

{
  "registration": {
    "email": {
      "required": true
    }
  }
}

Registration with optional email, but if email is supplied it is verified:

{
  "registration": {
    "email": {
      "verified": true
    }
  }
}

Registration with email and email is verified:

{
  "registration": {
    "email": {
      "required": true,
      "verified": true
    }
  }
}

from torrust-index.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.