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

String one of #158

Open
aminnairi opened this issue Dec 17, 2023 · 0 comments
Open

String one of #158

aminnairi opened this issue Dec 17, 2023 · 0 comments
Assignees
Labels
feature New feature or request
Milestone

Comments

@aminnairi
Copy link
Owner

Is your feature request related to a problem? Please describe.
It would be great to be able to check if a string is included in a set of values, and prevent other values from being used.

Describe the solution you'd like
Create a rule that will check if all values are in the set of authorized values.

import * as Kryptonian from "kryptonian";

Kryptonian.Kalel.string({
  message: "It should be a stirng",
  rules: [
    Kryptonian.Kalel.String.oneOf({
      message: "It should be one of the following values: Haskell, Elm or Roc",
      values: ["Haskell", "Elm", "Roc"]
    })
  ]
});

// Omiting the message
Kryptonian.Kalel.string({
  message: "It should be a stirng",
  rules: [
    Kryptonian.Kalel.String.oneOf({
      values: ["Haskell", "Elm", "Roc"]
    })
  ]
});

Describe alternatives you've considered
None.

Additional context
None.

@aminnairi aminnairi added the feature New feature or request label Dec 17, 2023
@aminnairi aminnairi added this to the 4.1.0 milestone Dec 17, 2023
@aminnairi aminnairi self-assigned this Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant