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

Constraints are overriding type in validation #21

Closed
igordrnobrega opened this issue Jun 8, 2017 · 3 comments
Closed

Constraints are overriding type in validation #21

igordrnobrega opened this issue Jun 8, 2017 · 3 comments

Comments

@igordrnobrega
Copy link
Contributor

igordrnobrega commented Jun 8, 2017

Creating an input with type and contraints defined It fails to assert that the type is correct.

public function testOverride()
{
    $input = [
        'price' => 'igor'
    ];

    $inputHandler = new TestConstraintOverrideType();
    $inputHandler->bind($input);
    $this->assertFalse($inputHandler->isValid());
}
 
 class TestConstraintOverrideType extends InputHandler
 {
     public function define()
     {
         $this->add('price', 'int', [
             'required' => true,
             'constraints' => [new Range(0)]
         ]);
     }
 }
@igordrnobrega
Copy link
Contributor Author

igordrnobrega@e04117a

@igordrnobrega
Copy link
Contributor Author

Creating an input with type and contraints defined It fails to assert that the type is correct

@nesl247
Copy link
Contributor

nesl247 commented Jun 9, 2017

The issue is here: https://github.com/LinioIT/input/blob/master/src/Node/BaseNode.php#L68 and https://github.com/LinioIT/input/blob/master/src/Node/BaseNode.php#L161.

The issue is that if the configuration has constraints, it calls setContraints which overrides what is added in the node's constructor.

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

2 participants