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

Type shortcuts #24

Merged
merged 3 commits into from
Sep 22, 2023
Merged

Type shortcuts #24

merged 3 commits into from
Sep 22, 2023

Conversation

solnic
Copy link
Owner

@solnic solnic commented Sep 22, 2023

This adds convenient type-check shortcuts:

%{
  # translates to required(:test) => type(:string)
  required(:test) => string(),

  # translates to required(:test) => type(:integer)
  required(:test) => integer(),

  # translates to required(:test) => type(:map)
  required(:test) => map()
}

You can use regular predicate syntax with these shortcuts too:

%{
  # translates to required(:test) => type(:string, [:filled?])
  required(:test) => string(:filled?),

  # translates to required(:test) => type(:integer, [:even?, gt?: 2])
  required(:test) => integer([:even?, gt?: 2]),

  # translates to required(:test) => type(:map, size?: 3)
  required(:test) => map(size?: 3)
}

@solnic solnic added the feature label Sep 22, 2023
@solnic solnic added this to the v0.1.0 milestone Sep 22, 2023
@solnic solnic merged commit 6322fea into main Sep 22, 2023
1 check passed
@solnic solnic deleted the type-shortcuts branch September 22, 2023 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant