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

[NFR] Validation messages code #1171

Closed
viktoras25 opened this issue Aug 29, 2013 · 0 comments
Closed

[NFR] Validation messages code #1171

viktoras25 opened this issue Aug 29, 2013 · 0 comments

Comments

@viktoras25
Copy link
Contributor

Currently messages (e.g. model messages) support only 3 parameters: field, text and type. I, however, find that code parameter is also important (as for me much more important than type). Message text may differ over time, if you want to reformulate it, or fix some typo, message code at the same time should stay always the same. It is unique identifier of an error in the system. Think of an exception, they do have type, message text and code.

Please, implement codes for messages. It would be also very nice if validators would accept a code as an option, to pass to a message.

It doesn't seem to be an unnecessary complication.

Thanks in advance.

Proposed changes:

$message = new Message($message, $field, $type, $code) {...}
$message->setCode(103);
$message->getCode(); // int(103)
// model.php
$this->validate(new PresenceOf(array(
    "message" => "Field required",
    "code" => 103
)));
phalcon pushed a commit that referenced this issue Sep 1, 2013
NFR #1171 Adding code support validation messages
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

1 participant