Skip to content

[Forms] [Feature request] prompt function #3864

@xDaizu

Description

@xDaizu

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions