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

model validator ignores message code #12645

Closed
ghost opened this issue Feb 21, 2017 · 4 comments
Closed

model validator ignores message code #12645

ghost opened this issue Feb 21, 2017 · 4 comments
Labels
bug A bug report status: low Low
Milestone

Comments

@ghost
Copy link

ghost commented Feb 21, 2017

Model validation

    public function validation()
    {

        $validator = new Validation();

        $validator->add(
            'email',
            new Uniqueness([
                'model' => $this,
                'message' => "The email must be unique.",
                'code' => 20
            ])
        );

        $this->validate($validator);

Uniquess validator properly sets the code but model.zep below ignores it.

	protected function validate(<ValidationInterface> validator) -> boolean
	{
		var messages, message;

		let messages = validator->validate(null, this);

		// Call the validation, if it returns not the boolean
		// we append the messages to the current object
		if typeof messages == "boolean" {
			return messages;
		}

		for message in iterator(messages) {
			this->appendMessage(
				new Message(
					message->getMessage(),
					message->getField(),
					message->getType()
				)
			);
		}

		// If there is a message, it returns false otherwise true
		return !count(messages);
	}
@dreamsxin
Copy link
Contributor

You can help fix it, Pull request.

@sergeyklay
Copy link
Contributor

Cc: @Jurigag

@Jurigag
Copy link
Contributor

Jurigag commented Feb 23, 2017

Tbh it's nothing that i was changing, that someone in model validate method forgot to add 4th argument in Message constructor.

@Jurigag
Copy link
Contributor

Jurigag commented Mar 8, 2017

Fixed in 3.1.x

@sergeyklay sergeyklay added this to the 3.1.x milestone Mar 9, 2017
@sergeyklay sergeyklay modified the milestones: 3.2.x, 3.2.0 Apr 8, 2017
@niden niden added bug A bug report status: low Low and removed Bug - Low labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
None yet
Development

No branches or pull requests

4 participants