Skip to content

Commit 4051c33

Browse files
Fix state validation - no error case (#1109)
* fix state validation - no error case * add return type
1 parent 0a14a04 commit 4051c33

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/validate/validate_state.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import {validateState} from './validate_state';
22

33
describe('Validate state', () => {
4+
test('Should return no error if type is an object', () => {
5+
const errors = validateState({key: 'state', value: {a: 1}});
6+
expect(errors).toHaveLength(0);
7+
});
8+
49
test('Should return error if type is not an object', () => {
510
const errors = validateState({key: 'state', value: 3});
611
expect(errors).toHaveLength(1);

src/validate/validate_state.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface ValidateStateOptions {
77
value: unknown;
88
}
99

10-
export function validateState(options: ValidateStateOptions) {
10+
export function validateState(options: ValidateStateOptions): ValidationError[] {
1111
if (!isObjectLiteral(options.value)) {
1212
return [
1313
new ValidationError(
@@ -17,4 +17,6 @@ export function validateState(options: ValidateStateOptions) {
1717
),
1818
];
1919
}
20+
21+
return [];
2022
}

0 commit comments

Comments
 (0)