Fixed issue where custom validation rules were not firing #21

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
@pusherman

Code was checking for the method name to have a prefix of callback_ which the methods did not. Took out that check, seems to be working as expected now.

@rickharrison

This comment has been minimized.

Show comment Hide comment
@rickharrison

rickharrison Apr 2, 2012

Owner

That is actually incorrect. This code checks to see if a rule has the prefix of callback_ which is required in the rule definition. A custom rule works in that you name it "callback_name_here" in the rules array and then register it like so:

validator.registerCallback('name_here', function() {
    return false;
});

This was designed to work the exact same as code igniter. If you think that this syntax is confusing, I am open to suggestions on a better option.

Owner

rickharrison commented Apr 2, 2012

That is actually incorrect. This code checks to see if a rule has the prefix of callback_ which is required in the rule definition. A custom rule works in that you name it "callback_name_here" in the rules array and then register it like so:

validator.registerCallback('name_here', function() {
    return false;
});

This was designed to work the exact same as code igniter. If you think that this syntax is confusing, I am open to suggestions on a better option.

@pusherman

This comment has been minimized.

Show comment Hide comment
@pusherman

pusherman Apr 2, 2012

Ahh, I see. I must have missed the part in your documentation where it says you name the rule with a callback_ prefix.

But yeah, this is kind of confusing to me. Why not just have the name match the function that's actually being called?

Ahh, I see. I must have missed the part in your documentation where it says you name the rule with a callback_ prefix.

But yeah, this is kind of confusing to me. Why not just have the name match the function that's actually being called?

@rickharrison

This comment has been minimized.

Show comment Hide comment
@rickharrison

rickharrison Apr 2, 2012

Owner

I assume code igniter chose to do it this way to avoid any possible collisions with other system rules. I may change this so that callback_ is not required as I am not necessarily tied to the ci implementation.

Owner

rickharrison commented Apr 2, 2012

I assume code igniter chose to do it this way to avoid any possible collisions with other system rules. I may change this so that callback_ is not required as I am not necessarily tied to the ci implementation.

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