예제 #1
0
 def by_path(ctx: ByPathContext):
     # Check for data types other than objects or arrays
     fltr = {
         "$and": [
             {
                 ctx.filter_dotpath: {
                     "$ne": None
                 }
             },
             *[{
                 k: v
             } for k, v in ctx.extra_filter.items()],
             # $expr >= 3.6, $type >= 3.4
             {
                 "$expr": {
                     "$not": [{
                         "$in": [{
                             "$type": f'${ctx.filter_dotpath}'
                         }, allowed_types]
                     }]
                 }
             }
         ]
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #2
0
 def by_path(ctx: ByPathContext):
     fltr = {
         "$and": [
             {
                 ctx.filter_dotpath: {
                     "$ne": None
                 }
             },
             *[{
                 k: v
             } for k, v in ctx.extra_filter.items()],
             {
                 f'{ctx.filter_dotpath}.type': {
                     '$nin': geojson_types
                 }
             },
             # $expr >= 3.6
             {
                 "$expr": {
                     "$eq": [{
                         "$type": f'${ctx.filter_dotpath}'
                     }, 'object']
                 }
             }
         ]
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #3
0
 def by_path(ctx: ByPathContext):
     fltr = {
         "$and": [
             {
                 ctx.filter_dotpath: {
                     "$ne": None
                 }
             },
             *[{
                 k: v
             } for k, v in ctx.extra_filter.items()],
             # $expr >= 3.6, $isArray >= 3.2
             {
                 "$expr": {
                     "$eq": [{
                         "$isArray": f"${ctx.filter_dotpath}"
                     }, True]
                 }
             },
             {
                 "$expr": {
                     "$ne": [{
                         "$size": f"${ctx.filter_dotpath}"
                     }, 2]
                 }
             },  # $expr >= 3.6
             # TODO: add element type check
         ]
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #4
0
 def by_path(ctx: ByPathContext):
     fltr = {
         '$and': [
             {
                 ctx.filter_dotpath: {
                     '$ne': None
                 }
             },
             {
                 ctx.filter_dotpath: {
                     '$not': self.DOMAIN_REGEX
                 }
             },
             {
                 ctx.filter_dotpath: {
                     '$not': self.IP_DOMAIN_REGEX
                 }
             },
             {
                 ctx.filter_dotpath: {
                     '$not':
                     re.compile(rf'\A[^@]+@({whitelist_regex})\Z')
                 }
             },
             *[{
                 k: v
             } for k, v in ctx.extra_filter.items()],
         ]
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #5
0
 def by_path(ctx: ByPathContext):
     fltr = {
         ctx.filter_dotpath: {
             '$not': scheme_regex,
             '$ne': None
         },
         **ctx.extra_filter
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #6
0
 def by_path(ctx: ByPathContext):
     choices = diff.new
     fltr = {
         ctx.filter_dotpath: {
             '$nin': choices,
             '$exists': True
         },
         **ctx.extra_filter
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #7
0
 def by_path(ctx: ByPathContext):
     # Find records which doesn't match to the regex
     fltr = {
         ctx.filter_dotpath: {
             '$not': regex,
             '$ne': None
         },
         **ctx.extra_filter
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #8
0
 def by_path(ctx: ByPathContext):
     fltr = {
         ctx.filter_dotpath: {
             '$not': re.compile(diff.new),
             '$ne': None,
             '$exists': True
         },
         **ctx.extra_filter
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #9
0
 def by_path(ctx: ByPathContext):
     fltr = {
         ctx.filter_dotpath: {
             '$ne': None
         },
         **ctx.extra_filter,
         "$expr": {
             "$lt": [{
                 "$strLenCP": f"${ctx.filter_dotpath}"
             }, diff.new]
         },  # >= 3.6
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #10
0
 def by_path(ctx: ByPathContext):
     email_regex = r"\A[^\W][A-Z0-9._%+-]+@[\p{L}0-9.-]+\.\p{L}+\Z"
     fltr = {
         ctx.filter_dotpath: {
             '$not': {
                 '$regex': email_regex,
                 '$options': 'i'
             },
             '$ne': None
         },
         **ctx.extra_filter
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #11
0
 def by_path(ctx: ByPathContext):
     # Find records with ip domains and raise error if found
     fltr = {
         "$and": [{
             ctx.filter_dotpath: {
                 '$ne': None
             }
         }, {
             ctx.filter_dotpath: self.IP_DOMAIN_REGEX
         }, {
             ctx.filter_dotpath: {
                 '$not': re.compile(rf'\A[^@]+@({whitelist_regex})\Z')
             }
         }, *[{
             k: v
         } for k, v in ctx.extra_filter.items()]]
     }
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)
예제 #12
0
 def by_path(ctx: ByPathContext):
     fltr = {ctx.filter_dotpath: {'$exists': False}, **ctx.extra_filter}
     check_empty_result(ctx.collection, ctx.filter_dotpath, fltr)