yafred / asn1-tool

A java tool to generate Java encoders and decoders from ASN.1 specifications.
MIT License
42 stars 22 forks source link

Even after applying size restrictions, the fields are not validating as expected. #26

Open ananddwivediDev opened 1 month ago

ananddwivediDev commented 1 month ago

Field Validation After Size Restriction: Even after applying size restrictions, the fields are not validating as expected.

so right now if our ASN file has below code

`Example DEFINITIONS AUTOMATIC TAGS ::= BEGIN

Flights ::= SEQUENCE { origin [0] IMPLICIT OCTET STRING ( SIZE( 3..6 ) ) OPTIONAL, seats INTEGER (100..200) }

END `

we see generated Flight class --> validate method has validation only present for seats which is type of Integer .

public static void validate(Flights instance) throws Exception { if (instance.getSeats() < 100) { throw new Exception("seats should not be < 100"); } if (instance.getSeats() > 200) { throw new Exception("seats should not be > 200"); } }

Ideally we should add validation for OCTET String and other data type as well in case missing .

ananddwivediDev commented 1 month ago

@yafred / @Flole998 FYI

ananddwivediDev commented 1 month ago

@Flole998 / @yafred Could you provide me access to create Merge request for this fix ?