aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/account.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-27 17:30:46 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:43:01 +0100
commita2431b7dcbc72c05101dcdbe631ff84a823aeb51 (patch)
tree09278a822905622a70ff976a75e09d99bc45639a /server/models/account/account.ts
parentfcaf1e0aa84213a1b1f1b1a44a3276eae35ebe70 (diff)
downloadPeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.tar.gz
PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.tar.zst
PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.zip
Refractor validators
Diffstat (limited to 'server/models/account/account.ts')
-rw-r--r--server/models/account/account.ts19
1 files changed, 7 insertions, 12 deletions
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index fff3ce087..c721656cb 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -2,17 +2,12 @@ import * as Sequelize from 'sequelize'
2import { 2import {
3 activityPubContextify, 3 activityPubContextify,
4 isAccountFollowersCountValid, 4 isAccountFollowersCountValid,
5 isAccountFollowersValid,
6 isAccountFollowingCountValid, 5 isAccountFollowingCountValid,
7 isAccountFollowingValid,
8 isAccountInboxValid,
9 isAccountOutboxValid,
10 isAccountPrivateKeyValid, 6 isAccountPrivateKeyValid,
11 isAccountPublicKeyValid, 7 isAccountPublicKeyValid,
12 isAccountSharedInboxValid,
13 isAccountUrlValid,
14 isUserUsernameValid 8 isUserUsernameValid
15} from '../../helpers' 9} from '../../helpers'
10import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
16import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants' 11import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants'
17import { sendDeleteAccount } from '../../lib/activitypub/send/send-delete' 12import { sendDeleteAccount } from '../../lib/activitypub/send/send-delete'
18 13
@@ -61,7 +56,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
61 allowNull: false, 56 allowNull: false,
62 validate: { 57 validate: {
63 urlValid: value => { 58 urlValid: value => {
64 const res = isAccountUrlValid(value) 59 const res = isActivityPubUrlValid(value)
65 if (res === false) throw new Error('URL is not valid.') 60 if (res === false) throw new Error('URL is not valid.')
66 } 61 }
67 } 62 }
@@ -111,7 +106,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
111 allowNull: false, 106 allowNull: false,
112 validate: { 107 validate: {
113 inboxUrlValid: value => { 108 inboxUrlValid: value => {
114 const res = isAccountInboxValid(value) 109 const res = isActivityPubUrlValid(value)
115 if (res === false) throw new Error('Inbox URL is not valid.') 110 if (res === false) throw new Error('Inbox URL is not valid.')
116 } 111 }
117 } 112 }
@@ -121,7 +116,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
121 allowNull: false, 116 allowNull: false,
122 validate: { 117 validate: {
123 outboxUrlValid: value => { 118 outboxUrlValid: value => {
124 const res = isAccountOutboxValid(value) 119 const res = isActivityPubUrlValid(value)
125 if (res === false) throw new Error('Outbox URL is not valid.') 120 if (res === false) throw new Error('Outbox URL is not valid.')
126 } 121 }
127 } 122 }
@@ -131,7 +126,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
131 allowNull: false, 126 allowNull: false,
132 validate: { 127 validate: {
133 sharedInboxUrlValid: value => { 128 sharedInboxUrlValid: value => {
134 const res = isAccountSharedInboxValid(value) 129 const res = isActivityPubUrlValid(value)
135 if (res === false) throw new Error('Shared inbox URL is not valid.') 130 if (res === false) throw new Error('Shared inbox URL is not valid.')
136 } 131 }
137 } 132 }
@@ -141,7 +136,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
141 allowNull: false, 136 allowNull: false,
142 validate: { 137 validate: {
143 followersUrlValid: value => { 138 followersUrlValid: value => {
144 const res = isAccountFollowersValid(value) 139 const res = isActivityPubUrlValid(value)
145 if (res === false) throw new Error('Followers URL is not valid.') 140 if (res === false) throw new Error('Followers URL is not valid.')
146 } 141 }
147 } 142 }
@@ -151,7 +146,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
151 allowNull: false, 146 allowNull: false,
152 validate: { 147 validate: {
153 followingUrlValid: value => { 148 followingUrlValid: value => {
154 const res = isAccountFollowingValid(value) 149 const res = isActivityPubUrlValid(value)
155 if (res === false) throw new Error('Following URL is not valid.') 150 if (res === false) throw new Error('Following URL is not valid.')
156 } 151 }
157 } 152 }