blob: be051894803a130406025add7301997e3885dfd7 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::validators::{Validator, ValidatorError},
fuchsia_syslog as syslog,
/// Validator that always returns `Ok`.
/// Used for allowing files to pass validation without any checks as by default, no files are
/// allowed to be exposed without going through at least one validator.
pub struct PassValidator;
impl Validator for PassValidator {
/// Pass through validation function. Always returns `Ok`.
fn validate(&self, file_name: &str, _contents: &[u8]) -> Result<(), ValidatorError> {
syslog::fx_log_info!("Passing validation of {}", file_name);
mod tests {
use super::*;
fn validate_with_text_succeeds() {
let validator = PassValidator;
let text = b"abcdefg";
validator.validate("file_to_validate", text).unwrap();
fn validate_with_empty_contents_succeeds() {
let validator = PassValidator;
let empty = [];
validator.validate("file_to_validate", &empty).unwrap();