Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove strict w3c subjectId uri validation #1805

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { IsOptional, ValidateBy, buildMessage, isInstance } from 'class-validator'

import { CredoError } from '../../../../error'
import { IsUri, isUri } from '../../../../utils/validators'

Check warning on line 7 in packages/core/src/modules/vc/models/credential/W3cCredentialSubject.ts

View workflow job for this annotation

GitHub Actions / Validate

'IsUri' is defined but never used

Check warning on line 7 in packages/core/src/modules/vc/models/credential/W3cCredentialSubject.ts

View workflow job for this annotation

GitHub Actions / Validate

'isUri' is defined but never used

/**
* @see https://www.w3.org/TR/vc-data-model/#credential-subject
Expand All @@ -27,7 +27,6 @@
}
}

@IsUri()
@IsOptional()
public id?: string

Expand Down Expand Up @@ -70,12 +69,11 @@
name: 'IsW3cCredentialSubject',
validator: {
validate: (value): boolean => {
return isInstance(value, W3cCredentialSubject) && (!value.id || isUri(value.id))
return isInstance(value, W3cCredentialSubject)
},
defaultMessage: buildMessage(
(eachPrefix) =>
eachPrefix +
'$property must be an object or an array of objects with an optional id property which is an URI',
eachPrefix + '$property must be an object or an array of objects with an optional id property',
validationOptions
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('W3cCredential', () => {
},
W3cCredential
)
).toThrow()
).not.toThrow()

expect(() =>
JsonTransformer.fromJSON(
Expand Down
Loading