Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Union #20

Closed
ellcs opened this issue May 18, 2020 · 0 comments
Closed

Feature Request: Union #20

ellcs opened this issue May 18, 2020 · 0 comments

Comments

@ellcs
Copy link

ellcs commented May 18, 2020

Hello james! I have a feature request. Most modern languages have a concept named union types:

The type is an element of a set. I know it's easy to write with as a lambda. But it's way better to read, when you have a notation like HashValidator::Union[*typesl]. Another name could be HashValidator::Or.

class Email; attr_accessor :text; end

# Validations hash
validators = {  email: HashValidator::Union[String, Email] }

# First case, it's a String
user1 =  { email: 'james@github.com' }
HashValidator.validate(user1, validations)

# Second case, it's an Email
email = Email.new
email.text = 'ellcs@github.com'
user2 =  { email: email }
HashValidator.validate(user2, validations)
@jamesbrooks jamesbrooks closed this as not planned Won't fix, can't repro, duplicate, stale Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants