()
| 456 | } |
| 457 | |
| 458 | validate() { |
| 459 | let value = {}; |
| 460 | let errors = []; |
| 461 | let hasError = false; |
| 462 | let result; |
| 463 | |
| 464 | if (this.typeInfo.isMaybe && this.isValueNully()) { |
| 465 | this.removeErrors(); |
| 466 | return new t.ValidationResult({ errors: [], value: null }); |
| 467 | } |
| 468 | |
| 469 | for (const ref in this.refs) { |
| 470 | if (this.refs.hasOwnProperty(ref)) { |
| 471 | result = this.refs[ref].validate(); |
| 472 | errors = errors.concat(result.errors); |
| 473 | value[ref] = result.value; |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | if (errors.length === 0) { |
| 478 | const InnerType = this.typeInfo.innerType; |
| 479 | value = new InnerType(value); |
| 480 | if (this.typeInfo.isSubtype && errors.length === 0) { |
| 481 | result = t.validate( |
| 482 | value, |
| 483 | this.props.type, |
| 484 | this.getValidationOptions() |
| 485 | ); |
| 486 | hasError = !result.isValid(); |
| 487 | errors = errors.concat(result.errors); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | this.setState({ hasError: hasError }); |
| 492 | return new t.ValidationResult({ errors, value }); |
| 493 | } |
| 494 | |
| 495 | onChange(fieldName, fieldValue, path) { |
| 496 | const value = t.mixin({}, this.state.value); |
nothing calls this directly
no test coverage detected