mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-22 21:15:35 +03:00
Send lease duration as number
This commit is contained in:
parent
39bc55e430
commit
52b81a27fb
1 changed files with 12 additions and 2 deletions
|
@ -4,7 +4,7 @@ import { Field, reduxForm } from 'redux-form';
|
|||
import { R_IPV4 } from '../../../helpers/constants';
|
||||
|
||||
const required = (value) => {
|
||||
if (value) {
|
||||
if (value || value === 0) {
|
||||
return false;
|
||||
}
|
||||
return 'Required field';
|
||||
|
@ -17,6 +17,15 @@ const ipv4 = (value) => {
|
|||
return false;
|
||||
};
|
||||
|
||||
const isPositive = (value) => {
|
||||
if ((value || value === 0) && (value <= 0)) {
|
||||
return 'Must be greater than 0';
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const toNumber = value => value && parseInt(value, 10);
|
||||
|
||||
const renderField = ({
|
||||
input, className, placeholder, type, disabled, meta: { touched, error },
|
||||
}) => (
|
||||
|
@ -104,8 +113,9 @@ const Form = (props) => {
|
|||
type="number"
|
||||
className="form-control"
|
||||
placeholder="Lease duration"
|
||||
validate={[required]}
|
||||
validate={[required, isPositive]}
|
||||
disabled={!enabled}
|
||||
normalize={toNumber}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue