Remove null values

This commit is contained in:
Yarmo Mackenbach 2022-11-17 21:09:42 +01:00
parent e9fdeb0bf8
commit c7bd4fe81e
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -76,11 +76,11 @@ class Claim {
} }
} }
this._uri = uri || null this._uri = uri || ''
this._fingerprint = fingerprint || null this._fingerprint = fingerprint || ''
this._status = E.ClaimStatus.INIT this._status = E.ClaimStatus.INIT
this._matches = null this._matches = []
this._verification = null this._verification = {}
} }
get uri () { get uri () {
@ -116,7 +116,7 @@ class Claim {
) )
} }
// Verify validity of URI // Verify validity of URI
if (uri && !validUrl.isUri(uri)) { if (uri.length > 0 && !validUrl.isUri(uri)) {
throw new Error('The URI was invalid') throw new Error('The URI was invalid')
} }
// Remove leading and trailing spaces // Remove leading and trailing spaces
@ -154,7 +154,7 @@ class Claim {
if (this._status !== E.ClaimStatus.INIT) { if (this._status !== E.ClaimStatus.INIT) {
throw new Error('This claim was already matched') throw new Error('This claim was already matched')
} }
if (this._uri === null) { if (this._uri.length === 0 || !validUrl.isUri(this._uri)) {
throw new Error('This claim has no URI') throw new Error('This claim has no URI')
} }
@ -206,7 +206,7 @@ class Claim {
if (this._status === E.ClaimStatus.VERIFIED) { if (this._status === E.ClaimStatus.VERIFIED) {
throw new Error('This claim has already been verified') throw new Error('This claim has already been verified')
} }
if (this._fingerprint === null) { if (this._fingerprint.length === 0) {
throw new Error('This claim has no fingerprint') throw new Error('This claim has no fingerprint')
} }