Fixed required bug
This commit is contained in:
parent
31a78c74de
commit
1475dbb88b
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "formsy-react",
|
||||
"version": "0.12.2",
|
||||
"version": "0.12.3",
|
||||
"main": "src/main.js",
|
||||
"dependencies": {
|
||||
"react": "^0.13.1"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "formsy-react",
|
||||
"version": "0.12.2",
|
||||
"version": "0.12.3",
|
||||
"description": "A form input builder and validator for React JS",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ Formsy.Form = React.createClass({displayName: "Form",
|
|||
var isValid = !validationResults.failed.length && !(this.props.validationErrors && this.props.validationErrors[component.props.name]);
|
||||
return {
|
||||
isRequired: isRequired,
|
||||
isValid: isValid,
|
||||
isValid: isRequired ? false : isValid,
|
||||
error: (function () {
|
||||
|
||||
if (isValid && !isRequired) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -493,4 +493,30 @@ it('should allow an undefined value to be updated to a value', function (done) {
|
|||
expect(inputComponent.getErrorMessage()).toBe('bar');
|
||||
});
|
||||
|
||||
it('should not be valid if it is required and required rule is true', function () {
|
||||
var TestInput = React.createClass({
|
||||
mixins: [Formsy.Mixin],
|
||||
render: function () {
|
||||
return <input value={this.getValue()}/>
|
||||
}
|
||||
});
|
||||
var TestForm = React.createClass({
|
||||
render: function () {
|
||||
return (
|
||||
<Formsy.Form>
|
||||
<TestInput name="A"
|
||||
required
|
||||
/>
|
||||
</Formsy.Form>
|
||||
);
|
||||
}
|
||||
});
|
||||
var form = TestUtils.renderIntoDocument(
|
||||
<TestForm/>
|
||||
);
|
||||
|
||||
var inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
|
||||
expect(inputComponent.isValid()).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ Formsy.Form = React.createClass({
|
|||
var isValid = !validationResults.failed.length && !(this.props.validationErrors && this.props.validationErrors[component.props.name]);
|
||||
return {
|
||||
isRequired: isRequired,
|
||||
isValid: isValid,
|
||||
isValid: isRequired ? false : isValid,
|
||||
error: (function () {
|
||||
|
||||
if (isValid && !isRequired) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue