1
Breeze의 클라이언트 측 유효성 검사에 [필수] 기능을 사용하려고합니다. 그렇게 할 수는 있지만 지금까지 내가 성공한 유일한 방법은 문자열을 이용하는 것뿐입니다. 부울과 동일한 작업을 시도하고 있지만 Breeze는 엔티티 유효성 검사를 인식하지 못합니다. 여기 새 엔터티의 유효성을 검사 할 때 breeze가 "필수"속성 유효성 검사 규칙이 실행되지 않는 이유는 무엇입니까?
var testEntity = UWRLService.createEntity(entityName, uwrl.customerData);
if (!testEntity.entityAspect.validateEntity()) { alert("Didn't VALIDATE!"); }
내 특정 속성 Z-유효성 검사를 가지고 있도록 내보기입니다 : 여기
[Table("Uwrl")]
public partial class Uwrl
{
public Uwrl()
{
}
[Key]
public int customerNumber { get; set; }
[Required]
[StringLength(40)]
public string customerName { get; set; }
[Required]
[StringLength(50)]
public string customerStatus {get;set;}
public int? taxId {get;set;}
[Required]
public bool coAdministration{get;set;}
유효성 검사 오류를 테스트하기 위해 내 컨트롤러 코드입니다 : 여기
내 도메인 코드입니다 그 안에 :
<td style="text-align:right">
Co-Administration:<select ng-model="uwrl.coAdministration" data-z-required>
<option></option>
<option value="True">Yes</option>
<option value="False">No</option>
</select>
</td>
customerName과 customerStatus 모두 작동합니다. customerStatus는 coAdministration 속성과 정확히 똑같은 선택 (드롭 다운)입니다. 어떻게 불리언을 검증합니까? 문자열의 유효성 검사는 완벽하게 작동합니다 ... 차이점은 무엇입니까?
coAdministration 속성이 nullable이 아니므로 breeze가 false로 초기화하고 있습니까? False가 null이 아니므로 필요한 유효성 검사가 실행되지 않습니다. createEntity를 호출 한 후에이 줄을 추가하여 확인하십시오 :'console.log (testEntity.coAdministration)' –
그래서이 말은 바꿀 필요가 있습니다 : [필수] public bool coAdministration {get; set;} 들어가기 : [필수] 공개 bool? – user1789573
네, 제 생각에는'console.log (testEntity.coAdministration)'이 돌아 왔습니다. –