Thanks to visit codestin.com
Credit goes to github.com

Skip to content

minLength and maxLength are not respected if pattern is specified #123

@Pasu4

Description

@Pasu4

JSF does not respect the minLength and maxLength fields of a string property if a pattern field is defined.

Current output:

>>> from jsf import JSF
>>> JSF({"type": "string", "minLength": 2, "maxLength": 3}).generate()
'ut'
>>> JSF({"type": "string", "minLength": 2, "maxLength": 3, "pattern": "^[A-Z]+$"}).generate()
'OPFJJDSPZOMZSWAXQXDBAGZYHZJDPSQXFJPRULKUYQLVITLJVCXINUFVULHXTCFZEJDU'
>>> JSF({"type": "string", "minLength": 100, "maxLength": 110, "pattern": "^[A-Z]+$"}).generate()
'DYDJNFOQDOVKAZYBSGYEICJWMMKYKYSLHMYWNKDPHZDSNJLNPRZLRBZYBXZJTABKXDOJHM'

Expected output:

>>> from jsf import JSF
>>> JSF({"type": "string", "minLength": 2, "maxLength": 3}).generate()
'ut'
>>> JSF({"type": "string", "minLength": 2, "maxLength": 3, "pattern": "^[A-Z]+$"}).generate()
'OPF'
>>> JSF({"type": "string", "minLength": 100, "maxLength": 110, "pattern": "^[A-Z]+$"}).generate()
'DYDJNFOQDOVKAZYBSGYEICJWMMKYKYSLHMYWNKDPHZDSNJLNPRZLRBZYBXZJTABKXDOJHMWHQLQHNSFZCRNJVUYWGSGRKZCZIGYASEVPA'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions