(data: typeof formData)
| 228 | } |
| 229 | |
| 230 | const validateAll = (data: typeof formData) => { |
| 231 | const newErrors: Record<string, string[]> = { |
| 232 | providerType: [], |
| 233 | providerId: validateProviderId(data.providerId), |
| 234 | issuerUrl: validateIssuerUrl(data.issuerUrl), |
| 235 | domain: validateDomain(data.domain), |
| 236 | clientId: [], |
| 237 | clientSecret: [], |
| 238 | entryPoint: [], |
| 239 | cert: [], |
| 240 | scopes: [], |
| 241 | callbackUrl: [], |
| 242 | audience: [], |
| 243 | } |
| 244 | |
| 245 | const providerType = data.providerType || 'oidc' |
| 246 | |
| 247 | if (providerType === 'oidc') { |
| 248 | newErrors.clientId = validateRequired('Client ID', data.clientId) |
| 249 | newErrors.clientSecret = validateRequired('Client Secret', data.clientSecret) |
| 250 | if (!data.scopes || !data.scopes.trim()) { |
| 251 | newErrors.scopes = ['Scopes are required for OIDC providers'] |
| 252 | } |
| 253 | } else if (providerType === 'saml') { |
| 254 | newErrors.entryPoint = validateIssuerUrl(data.entryPoint || '') |
| 255 | if (!newErrors.entryPoint.length && !data.entryPoint) { |
| 256 | newErrors.entryPoint = ['Entry Point URL is required for SAML providers'] |
| 257 | } |
| 258 | newErrors.cert = validateRequired('Certificate', data.cert) |
| 259 | } |
| 260 | |
| 261 | setErrors(newErrors) |
| 262 | return newErrors |
| 263 | } |
| 264 | |
| 265 | const hasAnyErrors = (errs: Record<string, string[]>) => |
| 266 | Object.values(errs).some((l) => l.length > 0) |
no test coverage detected