MCPcopy
hub / github.com/gcanti/tcomb-form-native / validate

Method validate

lib/components.js:625–651  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

623 }
624
625 validate() {
626 const value = [];
627 let errors = [];
628 let hasError = false;
629 let result;
630
631 if (this.typeInfo.isMaybe && this.isValueNully()) {
632 this.removeErrors();
633 return new t.ValidationResult({ errors: [], value: null });
634 }
635
636 for (let i = 0, len = this.state.value.length; i < len; i++) {
637 result = this.refs[i].validate();
638 errors = errors.concat(result.errors);
639 value.push(result.value);
640 }
641
642 // handle subtype
643 if (this.typeInfo.isSubtype && errors.length === 0) {
644 result = t.validate(value, this.props.type, this.getValidationOptions());
645 hasError = !result.isValid();
646 errors = errors.concat(result.errors);
647 }
648
649 this.setState({ hasError: hasError });
650 return new t.ValidationResult({ errors: errors, value: value });
651 }
652
653 onChange(value, keys, path, kind) {
654 const allkeys = toSameLength(value, keys, this.props.ctx.uidGenerator);

Callers 4

pureValidateMethod · 0.45
validateMethod · 0.45
validateMethod · 0.45
getTypeInfoFunction · 0.45

Calls 3

isValueNullyMethod · 0.95
removeErrorsMethod · 0.95
getValidationOptionsMethod · 0.80

Tested by

no test coverage detected