diff --git a/src/components/checkbox/__tests__/index.spec.tsx b/src/components/checkbox/__tests__/index.spec.tsx
index 411e137771..d0dc27e92e 100644
--- a/src/components/checkbox/__tests__/index.spec.tsx
+++ b/src/components/checkbox/__tests__/index.spec.tsx
@@ -158,6 +158,19 @@ describe('Checkbox renderer test', () => {
expect(onChangeValidity).toHaveBeenCalledWith(false);
});
+
+ it.each([false, true])('should return validity from validate function - initial %s', async (initialValue) => {
+ const props: CheckboxProps = {required: true, onChangeValidity, value: initialValue};
+ const renderTree = render();
+ const driver = CheckboxDriver({renderTree, testID});
+
+ expect(checkboxRef.current?.validate()).toBe(initialValue);
+
+ await driver.press();
+
+ expect(checkboxRef.current?.validate()).toBe(!initialValue);
+
+ });
});
describe('isValid', () => {
diff --git a/src/components/checkbox/index.tsx b/src/components/checkbox/index.tsx
index a2690cc927..c62801558e 100644
--- a/src/components/checkbox/index.tsx
+++ b/src/components/checkbox/index.tsx
@@ -306,9 +306,10 @@ class Checkbox extends Component {
validate = () => {
const {value, required} = this.props;
- const error = required && !value;
- this.validationState = true;
- this.setState({showError: error, isValid: !error});
+ const isValid = !(required && !value);
+ this.validationState = true;
+ this.setState({showError: !isValid, isValid});
+ return isValid;
};
isValid = () => {