@@ -13,27 +13,33 @@ final class IntSchema extends AbstractSchemaInnerParse implements SchemaInterfac
1313 public const string ERROR_TYPE_TEMPLATE = 'Type should be "int", {{given}} given ' ;
1414
1515 public const string ERROR_MINIMUM_CODE = 'int.minimum ' ;
16- public const string ERROR_MINIMUM_TEMPLATE = 'Value should be minimum {{minimum}} {{exclusiveMinimum}}, {{given}} given ' ;
16+ public const string ERROR_MINIMUM_TEMPLATE = 'Value should be minimum {{minimum}}, {{given}} given ' ;
17+
18+ public const string ERROR_EXCLUSIVE_MINIMUM_CODE = 'int.exclusiveMinimum ' ;
19+ public const string ERROR_EXCLUSIVE_MINIMUM_TEMPLATE = 'Value should be greater than {{exclusiveMinimum}}, {{given}} given ' ;
20+
21+ public const string ERROR_EXCLUSIVE_MAXIMUM_CODE = 'int.exclusiveMaximum ' ;
22+ public const string ERROR_EXCLUSIVE_MAXIMUM_TEMPLATE = 'Value should be lesser than {{exclusiveMaximum}}, {{given}} given ' ;
1723
1824 public const string ERROR_MAXIMUM_CODE = 'int.maximum ' ;
19- public const string ERROR_MAXIMUM_TEMPLATE = 'Value should be maximum {{maximum}} {{exclusiveMaximum}} , {{given}} given ' ;
25+ public const string ERROR_MAXIMUM_TEMPLATE = 'Value should be maximum {{maximum}}, {{given}} given ' ;
2026
2127 /** @deprecated: see ERROR_MINIMUM_CODE */
2228 public const string ERROR_GTE_CODE = 'int.gte ' ;
2329
2430 /** @deprecated: see ERROR_MINIMUM_TEMPLATE */
2531 public const string ERROR_GTE_TEMPLATE = 'Value should be greater than or equal {{gte}}, {{given}} given ' ;
2632
27- /** @deprecated: see ERROR_MINIMUM_CODE */
33+ /** @deprecated: see ERROR_EXCLUSIVE_MINIMUM_CODE */
2834 public const string ERROR_GT_CODE = 'int.gt ' ;
2935
30- /** @deprecated: see ERROR_MINIMUM_TEMPLATE */
36+ /** @deprecated: see ERROR_EXCLUSIVE_MINIMUM_TEMPLATE */
3137 public const string ERROR_GT_TEMPLATE = 'Value should be greater than {{gt}}, {{given}} given ' ;
3238
33- /** @deprecated: see ERROR_MAXIMUM_CODE */
39+ /** @deprecated: see ERROR_EXCLUSIVE_MAXIMUM_CODE */
3440 public const string ERROR_LT_CODE = 'int.lt ' ;
3541
36- /** @deprecated: see ERROR_MAXIMUM_TEMPLATE */
42+ /** @deprecated: see ERROR_EXCLUSIVE_MAXIMUM_TEMPLATE */
3743 public const string ERROR_LT_TEMPLATE = 'Value should be lesser than {{lt}}, {{given}} given ' ;
3844
3945 /** @deprecated: see ERROR_MAXIMUM_CODE */
@@ -42,35 +48,69 @@ final class IntSchema extends AbstractSchemaInnerParse implements SchemaInterfac
4248 /** @deprecated: see ERROR_MAXIMUM_TEMPLATE */
4349 public const string ERROR_LTE_TEMPLATE = 'Value should be lesser than or equal {{lte}}, {{given}} given ' ;
4450
45- public function minimum (int $ minimum, bool $ exclusiveMinimum = false ): static
51+ public function minimum (int $ minimum ): static
4652 {
47- return $ this ->postParse (static function (int $ int ) use ($ minimum, $ exclusiveMinimum ) {
48- if ((! $ exclusiveMinimum && $ int >= $ minimum) || ( $ exclusiveMinimum && $ int > $ minimum ) ) {
53+ return $ this ->postParse (static function (int $ int ) use ($ minimum ) {
54+ if ($ int >= $ minimum ) {
4955 return $ int ;
5056 }
5157
5258 throw new ErrorsException (
5359 new Error (
5460 self ::ERROR_MINIMUM_CODE ,
5561 self ::ERROR_MINIMUM_TEMPLATE ,
56- ['minimum ' => $ minimum , 'exclusiveMinimum ' => $ exclusiveMinimum , 'given ' => $ int ]
62+ ['minimum ' => $ minimum , 'given ' => $ int ]
63+ )
64+ );
65+ });
66+ }
67+
68+ public function exclusiveMinimum (int $ exclusiveMinimum ): static
69+ {
70+ return $ this ->postParse (static function (int $ int ) use ($ exclusiveMinimum ) {
71+ if ($ int > $ exclusiveMinimum ) {
72+ return $ int ;
73+ }
74+
75+ throw new ErrorsException (
76+ new Error (
77+ self ::ERROR_EXCLUSIVE_MINIMUM_CODE ,
78+ self ::ERROR_EXCLUSIVE_MINIMUM_TEMPLATE ,
79+ ['exclusiveMinimum ' => $ exclusiveMinimum , 'given ' => $ int ]
80+ )
81+ );
82+ });
83+ }
84+
85+ public function exclusiveMaximum (int $ exclusiveMaximum ): static
86+ {
87+ return $ this ->postParse (static function (int $ int ) use ($ exclusiveMaximum ) {
88+ if ($ int < $ exclusiveMaximum ) {
89+ return $ int ;
90+ }
91+
92+ throw new ErrorsException (
93+ new Error (
94+ self ::ERROR_EXCLUSIVE_MAXIMUM_CODE ,
95+ self ::ERROR_EXCLUSIVE_MAXIMUM_TEMPLATE ,
96+ ['exclusiveMaximum ' => $ exclusiveMaximum , 'given ' => $ int ]
5797 )
5898 );
5999 });
60100 }
61101
62- public function maximum (int $ maximum, bool $ exclusiveMaximum = false ): static
102+ public function maximum (int $ maximum ): static
63103 {
64- return $ this ->postParse (static function (int $ int ) use ($ maximum, $ exclusiveMaximum ) {
65- if ((! $ exclusiveMaximum && $ int <= $ maximum) || ( $ exclusiveMaximum && $ int < $ maximum ) ) {
104+ return $ this ->postParse (static function (int $ int ) use ($ maximum ) {
105+ if ($ int <= $ maximum ) {
66106 return $ int ;
67107 }
68108
69109 throw new ErrorsException (
70110 new Error (
71111 self ::ERROR_MAXIMUM_CODE ,
72112 self ::ERROR_MAXIMUM_TEMPLATE ,
73- ['maximum ' => $ maximum , 'exclusiveMaximum ' => $ exclusiveMaximum , ' given ' => $ int ]
113+ ['maximum ' => $ maximum , 'given ' => $ int ]
74114 )
75115 );
76116 });
@@ -99,11 +139,11 @@ public function gte(int $gte): static
99139 }
100140
101141 /**
102- * @deprecated Use minimum ($gt, true ) instead
142+ * @deprecated Use exclusiveMinimum ($gt) instead
103143 */
104144 public function gt (int $ gt ): static
105145 {
106- @trigger_error ('Use minimum ( ' .$ this ->varExport ($ gt ).', true ) instead ' , E_USER_DEPRECATED );
146+ @trigger_error ('Use exclusiveMinimum ( ' .$ this ->varExport ($ gt ).') instead ' , E_USER_DEPRECATED );
107147
108148 return $ this ->postParse (static function (int $ int ) use ($ gt ) {
109149 if ($ int > $ gt ) {
@@ -121,11 +161,11 @@ public function gt(int $gt): static
121161 }
122162
123163 /**
124- * @deprecated Use maximum ($lt, true ) instead
164+ * @deprecated Use exclusiveMaximum ($lt) instead
125165 */
126166 public function lt (int $ lt ): static
127167 {
128- @trigger_error ('Use maximum ( ' .$ this ->varExport ($ lt ).', true ) instead ' , E_USER_DEPRECATED );
168+ @trigger_error ('Use exclusiveMaximum ( ' .$ this ->varExport ($ lt ).') instead ' , E_USER_DEPRECATED );
129169
130170 return $ this ->postParse (static function (int $ int ) use ($ lt ) {
131171 if ($ int < $ lt ) {
0 commit comments