added internal validation

This commit is contained in:
christianalfoni 2015-04-01 13:59:52 +02:00
parent ebd17fde62
commit 8cbd6e19ff
4 changed files with 9 additions and 11 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -50,7 +50,7 @@ describe('Validation', function() {
});
it('should use provided checkValidity function', function () {
it('should use provided validate function', function () {
var isValid = jasmine.createSpy('valid');
var TestInput = React.createClass({
@ -64,7 +64,7 @@ describe('Validation', function() {
}
return <input value={this.getValue()} onChange={this.updateValue}/>
},
checkValidity: function () {
validate: function () {
return this.getValue() === "checkValidity";
}
});
@ -75,7 +75,6 @@ describe('Validation', function() {
);
var input = TestUtils.findRenderedDOMComponentWithTag(form, 'INPUT');
expect(isValid).not.toHaveBeenCalled();
TestUtils.Simulate.change(input, {target: {value: 'checkValidity'}});
expect(isValid).toHaveBeenCalled();

View File

@ -233,7 +233,7 @@ Formsy.Form = React.createClass({
}
var isValid = true;
if (component.validate) {
if (component.validate && typeof component.validate === 'function') {
isValid = component.validate();
} else if (component.props.required || component._validations) {
isValid = this.runValidation(component);