Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3358834
D11624.id39253.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11624.id39253.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 6:22 AM (20 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578434
Default Alt Text
D11624.id39253.diff (2 KB)
Attached To
Mode
D11624: [lib] Fix `farcasterRelationshipRequestValidator`
Attached
Detach File
Event Timeline
Log In to Comment