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

[Forms] [Feature request] prompt function #3864

Closed
xDaizu opened this issue Mar 23, 2016 · 1 comment
Closed

[Forms] [Feature request] prompt function #3864

xDaizu opened this issue Mar 23, 2016 · 1 comment

Comments

@xDaizu
Copy link

xDaizu commented Mar 23, 2016

Would it be possible to define rules like this:

email: {
                identifier: 'email',
                rules: [
                    {
                        type: 'empty',
                        prompt: options.messages.email_empty
                    },
                    {
                        type: 'email',
                        prompt: options.messages.email_invalid
                    },
                    {
                        type: 'checkRemoteValidity[email]',
                        prompt: foo
                    }
                ]
            },

where foo is a function called at validation time, which return a string, so when it validates it creates a customized prompt? Picture something like "The email [email protected] is already taken". Currently trying that fails with the error prompt.search is not a function because of the line:

requiresValue = (prompt.search('{value}') !== -1),

so maybe in the previous line:

 prompt = rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule,

we could try calling rule.prompt()? Would that work?

xDaizu added a commit to xDaizu/Semantic-UI that referenced this issue Dec 11, 2017
Allows the validation prompt to also be a function that returns a string, as discussed in [issue Semantic-Org#3864](Semantic-Org#3864)
@stale
Copy link

stale bot commented Feb 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants