File tree Expand file tree Collapse file tree 3 files changed +37
-4
lines changed
CatalogInventory/view/adminhtml/ui_component
Ui/view/base/web/js/lib/validation
dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation Expand file tree Collapse file tree 3 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
22<!--
33/**
4- * Copyright © Magento, Inc. All rights reserved.
5- * See COPYING.txt for license details .
4+ * Copyright 2016 Adobe
5+ * All rights reserved .
66 */
77-->
88<form xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:module:Magento_Ui:etc/ui_configuration.xsd" >
293293 <scopeLabel >[GLOBAL]</scopeLabel >
294294 <validation >
295295 <rule name =" validate-number" xsi : type =" boolean" >true</rule >
296- <rule name =" validate-greater-than-zero" xsi : type =" boolean" >true</rule >
296+ <rule name =" validate-nonempty-number- greater-than-zero" xsi : type =" boolean" >true</rule >
297297 </validation >
298298 <label translate =" true" >Maximum Qty Allowed in Shopping Cart</label >
299299 <dataScope >max_sale_qty</dataScope >
Original file line number Diff line number Diff line change 22 * Copyright © Magento, Inc. All rights reserved.
33 * See COPYING.txt for license details.
44 */
5-
5+ /* eslint-disable no-useless-escape */
6+ // jscs:disable no-useless-escape
67/**
78 * @api
89 */
@@ -626,6 +627,13 @@ define([
626627 } ,
627628 $ . mage . __ ( 'Please enter a number greater than 0, without comma in this field.' )
628629 ] ,
630+ 'validate-nonempty-number-greater-than-zero' : [
631+ function ( value ) {
632+ return ! isNaN ( utils . parseNumber ( value ) )
633+ && value > 0 && ( / ^ \s * - ? \d + ( [ , . ] \d + ) * \s * % ? \s * $ / ) . test ( value ) ;
634+ } ,
635+ $ . mage . __ ( 'Please enter a number greater than 0, without comma in this field.' )
636+ ] ,
629637 'validate-css-length' : [
630638 function ( value ) {
631639 if ( value !== '' ) {
Original file line number Diff line number Diff line change @@ -94,6 +94,31 @@ define([
9494 expect ( rules [ 'validate-number' ] . handler ( value ) ) . toBe ( false ) ;
9595 } ) ;
9696 } ) ;
97+ describe ( '"validate-nonempty-number-greater-than-zero" method' , function ( ) {
98+ it ( 'Check on empty value' , function ( ) {
99+ var value = '' ;
100+
101+ expect ( rules [ 'validate-nonempty-number-greater-than-zero' ] . handler ( value ) ) . toBe ( false ) ;
102+ } ) ;
103+
104+ it ( 'Check on integer' , function ( ) {
105+ var value = '125' ;
106+
107+ expect ( rules [ 'validate-nonempty-number-greater-than-zero' ] . handler ( value ) ) . toBe ( true ) ;
108+ } ) ;
109+
110+ it ( 'Check on zero' , function ( ) {
111+ var value = '0' ;
112+
113+ expect ( rules [ 'validate-nonempty-number-greater-than-zero' ] . handler ( value ) ) . toBe ( false ) ;
114+ } ) ;
115+
116+ it ( 'Check on not a number' , function ( ) {
117+ var value = 'string' ;
118+
119+ expect ( rules [ 'validate-nonempty-number-greater-than-zero' ] . handler ( value ) ) . toBe ( false ) ;
120+ } ) ;
121+ } ) ;
97122 } ) ;
98123
99124 describe ( 'validate-color' , function ( ) {
You can’t perform that action at this time.
0 commit comments