mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-29 13:27:43 +00:00
naptr flags validation
This commit is contained in:
parent
c24fbf53d9
commit
afadf9f290
@ -163,4 +163,8 @@ object DomainValidations {
|
|||||||
def validateMX_NAPTR_SRVData(number: Int, recordDataType: String, recordType: String): ValidatedNel[DomainValidationError, Int] =
|
def validateMX_NAPTR_SRVData(number: Int, recordDataType: String, recordType: String): ValidatedNel[DomainValidationError, Int] =
|
||||||
if (number >= INTEGER_MIN_VALUE && number <= INTEGER_MAX_VALUE) number.validNel
|
if (number >= INTEGER_MIN_VALUE && number <= INTEGER_MAX_VALUE) number.validNel
|
||||||
else InvalidMX_NAPTR_SRVData(number, INTEGER_MIN_VALUE, INTEGER_MAX_VALUE, recordDataType, recordType).invalidNel[Int]
|
else InvalidMX_NAPTR_SRVData(number, INTEGER_MIN_VALUE, INTEGER_MAX_VALUE, recordDataType, recordType).invalidNel[Int]
|
||||||
|
|
||||||
|
def validateNaptrFlag(value: String): ValidatedNel[DomainValidationError, String] =
|
||||||
|
if (value == "U" || value == "S" || value == "A" || value == "P") value.validNel
|
||||||
|
else InvalidNaptrFlag(value).invalidNel[String]
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ class BatchChangeValidations(
|
|||||||
case mx: MXData =>
|
case mx: MXData =>
|
||||||
validateMX_NAPTR_SRVData(mx.preference, "preference", "MX").asUnit |+| validateHostName(mx.exchange).asUnit
|
validateMX_NAPTR_SRVData(mx.preference, "preference", "MX").asUnit |+| validateHostName(mx.exchange).asUnit
|
||||||
case ns: NSData => validateHostName(ns.nsdname).asUnit
|
case ns: NSData => validateHostName(ns.nsdname).asUnit
|
||||||
case naptr: NAPTRData => validateMX_NAPTR_SRVData(naptr.preference, "preference", "NAPTR").asUnit |+| validateMX_NAPTR_SRVData(naptr.order, "order", "NAPTR").asUnit |+| validateHostName(naptr.replacement).asUnit
|
case naptr: NAPTRData => validateMX_NAPTR_SRVData(naptr.preference, "preference", "NAPTR").asUnit |+| validateMX_NAPTR_SRVData(naptr.order, "order", "NAPTR").asUnit |+| validateHostName(naptr.replacement).asUnit |+| validateNaptrFlag(naptr.flags).asUnit
|
||||||
case srv: SRVData => validateMX_NAPTR_SRVData(srv.priority, "priority", "SRV").asUnit |+| validateMX_NAPTR_SRVData(srv.port, "port", "SRV").asUnit |+| validateMX_NAPTR_SRVData(srv.weight, "weight", "SRV").asUnit |+| validateHostName(srv.target).asUnit
|
case srv: SRVData => validateMX_NAPTR_SRVData(srv.priority, "priority", "SRV").asUnit |+| validateMX_NAPTR_SRVData(srv.port, "port", "SRV").asUnit |+| validateMX_NAPTR_SRVData(srv.weight, "weight", "SRV").asUnit |+| validateHostName(srv.target).asUnit
|
||||||
case other =>
|
case other =>
|
||||||
InvalidBatchRecordType(other.toString, SupportedBatchChangeRecordTypes.get).invalidNel[Unit]
|
InvalidBatchRecordType(other.toString, SupportedBatchChangeRecordTypes.get).invalidNel[Unit]
|
||||||
|
@ -113,6 +113,12 @@ final case class InvalidMX_NAPTR_SRVData(param: Long, min: Long, max: Long, reco
|
|||||||
s"""Invalid $recordType $recordDataType: "${param.toString}", must be a number between $min and $max."""
|
s"""Invalid $recordType $recordDataType: "${param.toString}", must be a number between $min and $max."""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final case class InvalidNaptrFlag(value: String)
|
||||||
|
extends DomainValidationError {
|
||||||
|
def message: String =
|
||||||
|
s"""Invalid NAPTR flag value: '$value'. Valid NAPTR flag value must be U, S, A or P."""
|
||||||
|
}
|
||||||
|
|
||||||
final case class InvalidBatchRecordType(param: String, supported: Set[RecordType])
|
final case class InvalidBatchRecordType(param: String, supported: Set[RecordType])
|
||||||
extends DomainValidationError {
|
extends DomainValidationError {
|
||||||
def message: String =
|
def message: String =
|
||||||
|
@ -31,7 +31,7 @@ object DomainValidationErrorType extends Enumeration {
|
|||||||
// NOTE: once defined, an error code type cannot be changed!
|
// NOTE: once defined, an error code type cannot be changed!
|
||||||
val ChangeLimitExceeded, BatchChangeIsEmpty, GroupDoesNotExist, NotAMemberOfOwnerGroup,
|
val ChangeLimitExceeded, BatchChangeIsEmpty, GroupDoesNotExist, NotAMemberOfOwnerGroup,
|
||||||
InvalidDomainName, InvalidCname, InvalidLength, InvalidEmail, InvalidRecordType, InvalidPortNumber,
|
InvalidDomainName, InvalidCname, InvalidLength, InvalidEmail, InvalidRecordType, InvalidPortNumber,
|
||||||
InvalidIpv4Address, InvalidIpv6Address, InvalidIPAddress, InvalidTTL, InvalidMX_NAPTR_SRVData,
|
InvalidIpv4Address, InvalidIpv6Address, InvalidIPAddress, InvalidTTL, InvalidMX_NAPTR_SRVData, InvalidNaptrFlag,
|
||||||
InvalidBatchRecordType, ZoneDiscoveryError, RecordAlreadyExists, RecordDoesNotExist, InvalidUpdateRequest,
|
InvalidBatchRecordType, ZoneDiscoveryError, RecordAlreadyExists, RecordDoesNotExist, InvalidUpdateRequest,
|
||||||
CnameIsNotUniqueError, UserIsNotAuthorized, UserIsNotAuthorizedError, RecordNameNotUniqueInBatch,
|
CnameIsNotUniqueError, UserIsNotAuthorized, UserIsNotAuthorizedError, RecordNameNotUniqueInBatch,
|
||||||
RecordInReverseZoneError, HighValueDomainError, MissingOwnerGroupId, ExistingMultiRecordError,
|
RecordInReverseZoneError, HighValueDomainError, MissingOwnerGroupId, ExistingMultiRecordError,
|
||||||
@ -56,6 +56,7 @@ object DomainValidationErrorType extends Enumeration {
|
|||||||
case _: InvalidIPAddress => InvalidIPAddress
|
case _: InvalidIPAddress => InvalidIPAddress
|
||||||
case _: InvalidTTL => InvalidTTL
|
case _: InvalidTTL => InvalidTTL
|
||||||
case _: InvalidMX_NAPTR_SRVData => InvalidMX_NAPTR_SRVData
|
case _: InvalidMX_NAPTR_SRVData => InvalidMX_NAPTR_SRVData
|
||||||
|
case _: InvalidNaptrFlag => InvalidNaptrFlag
|
||||||
case _: InvalidBatchRecordType => InvalidBatchRecordType
|
case _: InvalidBatchRecordType => InvalidBatchRecordType
|
||||||
case _: ZoneDiscoveryError => ZoneDiscoveryError
|
case _: ZoneDiscoveryError => ZoneDiscoveryError
|
||||||
case _: RecordAlreadyExists => RecordAlreadyExists
|
case _: RecordAlreadyExists => RecordAlreadyExists
|
||||||
|
@ -281,7 +281,7 @@
|
|||||||
<br />
|
<br />
|
||||||
|
|
||||||
<label class="batch-label">Flags</label>
|
<label class="batch-label">Flags</label>
|
||||||
<input name="record_naptr_flags_{{$index}}" type="text" ng-model="change.record.flags" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. U, S, A or P">
|
<select name="record_naptr_flags_{{$index}}" type="text" ng-model="change.record.flags" ng-required="change.changeType=='Add'" ng-options="flag for flag in naptrFlags" class="form-control" placeholder="e.g. U, S, A or P"></select>
|
||||||
<p ng-show="createBatchChangeForm.$submitted">
|
<p ng-show="createBatchChangeForm.$submitted">
|
||||||
<span ng-show="createBatchChangeForm.record_naptr_flags_{{$index}}.$error.required" class="batch-change-error-help">Flags is required!</span>
|
<span ng-show="createBatchChangeForm.record_naptr_flags_{{$index}}.$error.required" class="batch-change-error-help">Flags is required!</span>
|
||||||
</p>
|
</p>
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
$scope.allowManualReview = false;
|
$scope.allowManualReview = false;
|
||||||
$scope.confirmationPrompt = "Are you sure you want to submit this batch change request?";
|
$scope.confirmationPrompt = "Are you sure you want to submit this batch change request?";
|
||||||
$scope.manualReviewEnabled;
|
$scope.manualReviewEnabled;
|
||||||
|
$scope.naptrFlags = ["U", "S", "A", "P"];
|
||||||
|
|
||||||
$scope.addSingleChange = function() {
|
$scope.addSingleChange = function() {
|
||||||
$scope.newBatch.changes.push({changeType: "Add", type: "A+PTR"});
|
$scope.newBatch.changes.push({changeType: "Add", type: "A+PTR"});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user