UI FIX: null=>empty for: Schedule.propertyName, Schedule.propertyType
This commit is contained in:
parent
e8f3380793
commit
8d8b5513a2
@ -1,4 +1,4 @@
|
||||
import {validateBooleanNotNull, validateListOrEmpty, validateNumberNotNull, validateStringNotEmptyNotNull} from "../validators";
|
||||
import {validateBooleanNotNull, validateListOrEmpty, validateNumberNotNull, validateStringNotEmptyNotNull, validateStringNullToEmpty} from "../validators";
|
||||
import {ScheduleEntry} from "./entry/ScheduleEntry";
|
||||
|
||||
export class Schedule {
|
||||
@ -19,8 +19,8 @@ export class Schedule {
|
||||
validateNumberNotNull(json['id']),
|
||||
validateBooleanNotNull(json['enabled']),
|
||||
validateStringNotEmptyNotNull(json['name']),
|
||||
validateStringNotEmptyNotNull(json['propertyName']),
|
||||
validateStringNotEmptyNotNull(json['propertyType']),
|
||||
validateStringNullToEmpty(json['propertyName']),
|
||||
validateStringNullToEmpty(json['propertyType']),
|
||||
validateListOrEmpty(json['entries'], ScheduleEntry.fromJson, ScheduleEntry.compare),
|
||||
);
|
||||
}
|
||||
|
||||
@ -27,6 +27,20 @@ export function validateNumberAllowNull(value: any): number | null {
|
||||
return validateNumberNotNull(value);
|
||||
}
|
||||
|
||||
export function validateStringEmptyToNull(value: any): string | null {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return null;
|
||||
}
|
||||
return validateStringNotEmptyNotNull(value);
|
||||
}
|
||||
|
||||
export function validateStringNullToEmpty(value: any): string {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return '';
|
||||
}
|
||||
return validateStringNotEmptyNotNull(value);
|
||||
}
|
||||
|
||||
export function validateStringNotEmptyNotNull(value: any): string {
|
||||
if (!(typeof value === 'string')) {
|
||||
throw new Error("Not a string: " + value);
|
||||
@ -37,13 +51,6 @@ export function validateStringNotEmptyNotNull(value: any): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
export function validateStringNotEmpty_AllowNull(value: any): string | null {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return null;
|
||||
}
|
||||
return validateStringNotEmptyNotNull(value);
|
||||
}
|
||||
|
||||
function validateDateNotNull(value: any): Date {
|
||||
const number: number = Date.parse(value);
|
||||
if (isNaN(number)) {
|
||||
|
||||
@ -6,10 +6,13 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.firewall.HttpFirewall;
|
||||
import org.springframework.security.web.firewall.StrictHttpFirewall;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@ -29,11 +32,24 @@ public class WebConfig extends WebSecurityConfigurerAdapter implements WebMvcCon
|
||||
http.authorizeRequests().anyRequest().permitAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(WebSecurity web) {
|
||||
web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
|
||||
final StrictHttpFirewall firewall = new StrictHttpFirewall();
|
||||
firewall.setAllowUrlEncodedSlash(true);
|
||||
firewall.setAllowSemicolon(true);
|
||||
return firewall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowCredentials(true).allowedOrigins("http://localhost:4200").allowedMethods("*");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user