@@ -12,6 +12,7 @@ import { inject as service } from '@ember/service';
1212import EventWizardMixin from 'open-event-frontend/mixins/event-wizard' ;
1313import { protocolLessValidUrlPattern } from 'open-event-frontend/utils/validators' ;
1414import ENV from 'open-event-frontend/config/environment' ;
15+ import $ from 'jquery' ;
1516
1617export default Component . extend ( FormMixin , EventWizardMixin , {
1718
@@ -128,6 +129,12 @@ export default Component.extend(FormMixin, EventWizardMixin, {
128129
129130 // TODO: Removing the Event Time Validations due to the weird and buggy behaviour. Will be restored once a perfect solution is found. Please check issue: https://github.com/fossasia/open-event-frontend/issues/3667
130131 getValidationRules ( ) {
132+ $ . fn . form . settings . rules . checkMaxMinPrice = ( ) => {
133+ return $ ( '.ui.form' ) . form ( 'get value' , 'min_price' ) <= $ ( '.ui.form' ) . form ( 'get value' , 'max_price' ) ;
134+ } ;
135+ $ . fn . form . settings . rules . checkMaxMinOrder = ( ) => {
136+ return $ ( '.ui.form' ) . form ( 'get value' , 'ticket_min_order' ) <= $ ( '.ui.form' ) . form ( 'get value' , 'ticket_max_order' ) ;
137+ } ;
131138
132139 let validationRules = {
133140 inline : true ,
@@ -257,6 +264,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
257264 {
258265 type : 'number' ,
259266 prompt : this . l10n . t ( 'Invalid number' )
267+ } ,
268+ {
269+ type : 'checkMaxMinOrder' ,
270+ prompt : this . l10n . t ( 'Minimum order should not be greater than maximum' )
260271 }
261272 ]
262273 } ,
@@ -274,6 +285,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
274285 {
275286 type : 'integer[1..]' ,
276287 prompt : this . l10n . t ( 'Maximum tickets per order should be greater than 0' )
288+ } ,
289+ {
290+ type : 'checkMaxMinOrder' ,
291+ prompt : this . l10n . t ( 'Maximum order should not be less than minimum' )
277292 }
278293 ]
279294 } ,
@@ -287,6 +302,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
287302 {
288303 type : 'integer[1..]' ,
289304 prompt : this . l10n . t ( 'Minimum price needs to be greater than zero' )
305+ } ,
306+ {
307+ type : 'checkMaxMinPrice' ,
308+ prompt : this . l10n . t ( 'Minimum price should not be greater than maximum' )
290309 }
291310 ]
292311 } ,
@@ -300,6 +319,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
300319 {
301320 type : 'integer[1..]' ,
302321 prompt : this . l10n . t ( 'Maximum price needs to be greater than zero' )
322+ } ,
323+ {
324+ type : 'checkMaxMinPrice' ,
325+ prompt : this . l10n . t ( 'Maximum price should not be less than minimum' )
303326 }
304327 ]
305328 } ,
0 commit comments