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

Attachment reference regular expression constraint #25

Closed
OldSneerJaw opened this issue May 23, 2018 · 1 comment
Closed

Attachment reference regular expression constraint #25

OldSneerJaw opened this issue May 23, 2018 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@OldSneerJaw
Copy link
Owner

Feature Request

Description

Add a new constraint to the attachmentReference validation type that specifies a regular expression pattern that the corresponding attachment's filename must match. Should take precedence over the document-wide attachmentConstraints.filenameRegexPattern constraint.

Examples

With a static value:

myDoc1: {
  typeFilter: simpleTypeFilter,
  authorizedRoles: { write: 'write' },
  allowAttachments: true,
  propertyValidators: {
    myAttachmentProperty: {
      type: 'attachmentReference',
      regexPattern: /^[a-z]+-\d{1,4}\.xml$/
    }
  }
}

And with a dynamic value:

myDoc2: {
  typeFilter: simpleTypeFilter,
  authorizedRoles: { write: 'write' },
  allowAttachments: true,
  propertyValidators: {
    myAttachmentProperty: {
      type: 'attachmentReference',
      regexPattern: function(doc, oldDoc, value, oldValue) {
        return new RegExp('^' + doc._id + '-\\d{2}\\.pdf$');
      }
    }
  }
}
@OldSneerJaw OldSneerJaw added the enhancement New feature or request label May 23, 2018
OldSneerJaw added a commit that referenced this issue May 30, 2018
…ences

When included in a document definition, the `attachmentReference` validation type's `regexPattern` constraint verifies that the value conforms to the specified regular expression pattern. It overrides the value of the document-wide `attachmentConstraints.filenameRegexPattern` constraint for that attachment reference.
@OldSneerJaw OldSneerJaw self-assigned this May 30, 2018
@dkichler
Copy link
Collaborator

Satisfied by #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants