external lightning address validator (#2056)
This commit is contained in:
parent
2d51a5def9
commit
88253e5478
@ -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')
|
||||||
|
@ -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'
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user