corretto altro ts...

ora manca ancora il vuelidate
This commit is contained in:
paolo
2018-11-08 01:09:33 +01:00
parent 6811202571
commit 6522a88eb7
34 changed files with 537 additions and 339 deletions

View File

@@ -1,23 +1,23 @@
type t = string | number;
type fn = () => t[];
type t = string | number
type fn = () => t[]
export function duplicate(matches: t[] | fn, ignoreCase: boolean = false) {
if (Array.isArray(matches)) return factory(matches, ignoreCase);
export function duplicate(matches: t[] | fn, ignoreCase: boolean = false): any {
if (Array.isArray(matches)) return factory(matches, ignoreCase)
return value => {
let cb = factory(matches(), ignoreCase);
return cb(value);
};
return (value: any) => {
let cb = factory(matches(), ignoreCase)
return cb(value)
}
}
function factory(values: t[], ignoreCase: boolean) {
return value => {
function factory(values: t[], ignoreCase: boolean): any {
return (value: any) => {
if (value === undefined || value === null || values.length === 0)
return true;
else{
let flags = ignoreCase ? "i" : "";
let exp = new RegExp(`^(${value})$`, flags);
return values.find(o => exp.test(o.toString())) === undefined;
return true
else {
let flags = ignoreCase ? 'i' : ''
let exp = new RegExp(`^(${value})$`, flags)
return values.find(o => exp.test(o.toString())) === undefined
}
};
}
}

View File

@@ -1,22 +1,22 @@
import { default as Axios, AxiosResponse } from 'axios';
import { IPayload } from '../model';
import { GlobalConfig, PayloadMessageTypes } from '../common';
import { default as Axios, AxiosResponse } from 'axios'
import { IPayload } from '../model'
import { GlobalConfig, PayloadMessageTypes } from '../common'
const AUTH_URL = GlobalConfig.uri.auth;
const VALIDATE_USER_URL = AUTH_URL + 'validateuser';
const AUTH_URL = GlobalConfig.uri.auth
const VALIDATE_USER_URL = AUTH_URL + 'validateuser'
export function registered(userName: string) {
let config = {
params: { userName: userName }
};
}
let onSuccess = (res: AxiosResponse) => {
let payload: IPayload<boolean> = res.data;
return payload.message.messageTypeId !== PayloadMessageTypes.failure;
let payload: IPayload<boolean> = res.data
return payload.message.messageTypeId !== PayloadMessageTypes.failure
}
return Axios.get(VALIDATE_USER_URL, config)
.then(onSuccess);
.then(onSuccess)
};
}