Fixed equalsField rule
This commit is contained in:
parent
1e9ff5e527
commit
785ac0ca54
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "formsy-react",
|
||||
"version": "0.11.1",
|
||||
"version": "0.11.2",
|
||||
"main": "src/main.js",
|
||||
"dependencies": {
|
||||
"react": "^0.11.2 || ^0.13.1"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "formsy-react",
|
||||
"version": "0.11.1",
|
||||
"version": "0.11.2",
|
||||
"description": "A form input builder and validator for React JS",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
|||
|
|
@ -627,10 +627,10 @@ module.exports = {
|
|||
return this.state._isPristine;
|
||||
},
|
||||
isRequired: function () {
|
||||
return this.state._isRequired;
|
||||
return !!this.props.required;
|
||||
},
|
||||
showRequired: function () {
|
||||
return this.isRequired();
|
||||
return this.state._isRequired;
|
||||
},
|
||||
showError: function () {
|
||||
return !this.showRequired() && !this.isValid();
|
||||
|
|
@ -715,7 +715,7 @@ module.exports = {
|
|||
return value == eql;
|
||||
},
|
||||
equalsField: function (values, value, field) {
|
||||
return value == this[field];
|
||||
return value == values[field];
|
||||
},
|
||||
maxLength: function (values, value, length) {
|
||||
return value !== undefined && value.length <= length;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -220,4 +220,26 @@ describe('Validation', function() {
|
|||
|
||||
});
|
||||
|
||||
it('RULE: equalsField', function () {
|
||||
|
||||
var TestInput = React.createClass({
|
||||
mixins: [Formsy.Mixin],
|
||||
render: function () {
|
||||
return <input value={this.getValue()}/>
|
||||
}
|
||||
});
|
||||
var form = TestUtils.renderIntoDocument(
|
||||
<Formsy.Form>
|
||||
<TestInput name="foo" value="foo" validations="equalsField:bar"/>
|
||||
<TestInput name="bar" value="foo" validations="equalsField:foobar"/>
|
||||
<TestInput name="foobar" value="bar"/>
|
||||
</Formsy.Form>
|
||||
);
|
||||
|
||||
var input = TestUtils.scryRenderedComponentsWithType(form, TestInput);
|
||||
expect(input[0].isValid()).toBe(true);
|
||||
expect(input[1].isValid()).toBe(false);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue