Page MenuHomePhabricator

D11624.diff
No OneTemporary

D11624.diff

diff --git a/lib/types/relationship-types.js b/lib/types/relationship-types.js
--- a/lib/types/relationship-types.js
+++ b/lib/types/relationship-types.js
@@ -83,15 +83,10 @@
| TraditionalRelationshipRequest
| FarcasterRelationshipRequest;
-const exactlyTwoDictEntriesValidator = t.refinement(
- t.dict(t.String, t.String),
- dict => Object.keys(dict).length === 2,
-);
-
export const farcasterRelationshipRequestValidator: TInterface<FarcasterRelationshipRequest> =
tShape<FarcasterRelationshipRequest>({
action: tString('farcaster'),
- userIDsToFID: exactlyTwoDictEntriesValidator,
+ userIDsToFID: t.dict(t.String, t.String),
});
type SharedRelationshipRow = {
diff --git a/lib/types/relationship-types.test.js b/lib/types/relationship-types.test.js
--- a/lib/types/relationship-types.test.js
+++ b/lib/types/relationship-types.test.js
@@ -3,7 +3,7 @@
import { farcasterRelationshipRequestValidator } from './relationship-types.js';
describe('updateFarcasterRelationshipInputValidator', () => {
- test('SHOULD validate input with exactly 2 userIDsToFID entries', () => {
+ test('SHOULD validate input with 2 userIDsToFID entries', () => {
const input = {
action: 'farcaster',
userIDsToFID: {
@@ -14,28 +14,6 @@
expect(farcasterRelationshipRequestValidator.is(input)).toBe(true);
});
- test('SHOULD NOT validate input with > 2 userIDsToFID entries', () => {
- const input = {
- action: 'farcaster',
- userIDsToFID: {
- '256': 'f256',
- '512': 'f512',
- '1024': 'f1024',
- },
- };
- expect(farcasterRelationshipRequestValidator.is(input)).toBe(false);
- });
-
- test('SHOULD NOT validate input with < 2 userIDsToFID entries', () => {
- const input = {
- action: 'farcaster',
- userIDsToFID: {
- '256': 'f256',
- },
- };
- expect(farcasterRelationshipRequestValidator.is(input)).toBe(false);
- });
-
test('Should not validate if action is not farcaster', () => {
const input = {
action: 'NOT_FARCASTER',

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 5:07 AM (19 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578434
Default Alt Text
D11624.diff (2 KB)

Event Timeline