Skip to content

Commit

Permalink
✨ Add validators for Anoncreds models
Browse files Browse the repository at this point in the history
(Resolves openwallet-foundation#3519)

Signed-off-by: ff137 <[email protected]>
  • Loading branch information
ff137 committed Feb 13, 2025
1 parent 3b8d91e commit 4e44552
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions acapy_agent/messaging/valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,9 @@ class AnoncredsCredDefId(Regexp):
"""Validate value against anoncreds credential definition identifier specification."""

EXAMPLE = "did:(method):3:CL:20:tag"
PATTERN = r"^(.+$)"
PATTERN = (
r"^did:(?P<method>[a-zA-Z0-9]+):3:CL:(?P<schema_id>\d+):(?P<tag>[a-zA-Z0-9_-]+)$"
)

def __init__(self):
"""Initialize the instance."""
Expand Down Expand Up @@ -531,7 +533,10 @@ class AnoncredsSchemaId(Regexp):
"""Validate value against indy schema identifier specification."""

EXAMPLE = "did:(method):2:schema_name:1.0"
PATTERN = r"^(.+$)"
PATTERN = (
r"^did:(?P<method>[a-zA-Z0-9]+):2:(?P<schema_name>[a-zA-Z0-9_-]+):"
r"(?P<version>[0-9.]+)$"
)

def __init__(self):
"""Initialize the instance."""
Expand Down Expand Up @@ -566,7 +571,10 @@ class AnoncredsRevRegId(Regexp):
"""Validate value against anoncreds revocation registry identifier specification."""

EXAMPLE = "did:(method):4:did:<method>:3:CL:20:tag:CL_ACCUM:0"
PATTERN = r"^(.+$)"
PATTERN = (
r"^did:(?P<method>[a-zA-Z0-9]+):4:did:(?P<method>[a-zA-Z0-9]+):3:CL:"
r"(?P<schema_id>\d+):(?P<tag>[a-zA-Z0-9_-]+):CL_ACCUM:(.+)$"
)

def __init__(self):
"""Initialize the instance."""
Expand Down

0 comments on commit 4e44552

Please sign in to comment.