jsf icon indicating copy to clipboard operation
jsf copied to clipboard

`minLength` and `maxLength` are not respected if `pattern` is specified

Open Pasu4 opened this issue 8 months ago • 1 comments

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'

Pasu4 avatar Apr 24 '25 19:04 Pasu4