external lightning address validator (#2056)

This commit is contained in:
ekzyis 2025-04-02 00:39:33 +02:00 committed by GitHub
parent 2d51a5def9
commit 88253e5478
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View File

@ -51,6 +51,12 @@ export const lightningAddressValidator = process.env.NODE_ENV === 'development'
'address is no good') 'address is no good')
: string().email('address is no good') : string().email('address is no good')
export const externalLightningAddressValidator = lightningAddressValidator.test({
name: 'address',
test: addr => !addr.toLowerCase().endsWith('@stacker.news'),
message: 'lightning address must be external'
})
async function usernameExists (name, { client, models }) { async function usernameExists (name, { client, models }) {
if (!client && !models) { if (!client && !models) {
throw new Error('cannot check for user') throw new Error('cannot check for user')

View File

@ -1,4 +1,4 @@
import { lightningAddressValidator } from '@/lib/validate' import { externalLightningAddressValidator } from '@/lib/validate'
export const name = 'lightning-address' export const name = 'lightning-address'
export const shortName = 'lnAddr' export const shortName = 'lnAddr'
@ -12,11 +12,7 @@ export const fields = [
type: 'text', type: 'text',
autoComplete: 'off', autoComplete: 'off',
serverOnly: true, serverOnly: true,
validate: lightningAddressValidator.test({ validate: externalLightningAddressValidator
name: 'address',
test: addr => !addr.toLowerCase().endsWith('@stacker.news'),
message: 'lightning address must be external'
})
} }
] ]